Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extlib gem breaks further usage of Arrays, passed as splat argument to the method with keyword arguments in Ruby 2.3 #123

Open
GolubevV opened this issue Apr 12, 2017 · 0 comments

Comments

@GolubevV
Copy link

I am using Chef nexus cookbook, which manages Nexus configuration and is using nexus-cli gem under the curtains.Everything works well on Chef 11 with Ruby 1.9.3

However when running cookbook and gem on Chef 12 with Ruby 2.3, the previously working functionality gets broken due to incorrect Array argument expand when it is passed to the method via splat ( *) parameter.

The problem is coming from the fact, that extlib gem usage adds to_hash method to the Array class here, which results in incorrect keyword argument expand on Ruby 2.3 - more info about keyword arguments

Here is an example from PRY:

[1] pry(main)> def test_method(*args, **opts) puts "Args are: #{args}"; puts "Opts are: #{opts}" end
=> :test_method
[2] pry(main)> test_method('key',['value'])
Args are: ["key", ["value"]]
Opts are: {}
=> nil
[3] pry(main)> require 'extlib'
=> true
[4] pry(main)> test_method('key',['value'])
Args are: ["key", {"value"=>nil}]
Opts are: {}
=> nil

As such, this behavior breaks functionality of Chef, for example, for group management operations which is calling shell_out_compact! method:

# call method, which is using keyword arguments:
def manage_group
  shell_out_compact!("groupmod", set_options)
  modify_group_members
end

# definitions of the shell_out method
def shell_out_compact!(*args, **options)
  if options.empty?
    shell_out!(*clean_array(*args))
  else
    shell_out!(*clean_array(*args), **options)
  end
end

So question here - is the usage of 'extlib' gem still required for nexus_cli when running it on Ruby 2.3. Can nexus_cli gem be refactored not to use it at least for Ruby 2.3+

@GolubevV GolubevV changed the title Extlib gem breaks further usage of Arrays, passed as plat argument to the method with keyword arguments in Ruby 2.3 Extlib gem breaks further usage of Arrays, passed as splat argument to the method with keyword arguments in Ruby 2.3 Apr 12, 2017
mbakhoff pushed a commit to mbakhoff/nexus_cli that referenced this issue Mar 6, 2018
pmaccamp added a commit to pmaccamp/nexus_cli that referenced this issue Mar 25, 2021
drop chozo+extlib in configuration parsing (fixes RiotGamesMinions#123)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant