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

Conflict between knife/knife.rb and Berkshelf 2.x #314

Open
rberger opened this issue Oct 9, 2013 · 2 comments
Open

Conflict between knife/knife.rb and Berkshelf 2.x #314

rberger opened this issue Oct 9, 2013 · 2 comments

Comments

@rberger
Copy link
Contributor

rberger commented Oct 9, 2013

Tried to upgrade to Berkshelf 2.x and found that there is a conflict between the line in knife/knife.rb:

def load_if_exists(file) ; load(file) if File.exists?(file) ; end

It shows up if you run any berks 2.x commands:

berks --help
/Users/rberger/.rvm/gems/ruby-1.9.3-p429/gems/berkshelf-2.0.10/lib/berkshelf/mixin/config.rb:106:in `load': wrong number of arguments (1 for 0) (ArgumentError)
    from /Users/rberger/work/runa/GargleBlaster/.chef/knife.rb:57:in `load_if_exists'
    from /Users/rberger/work/runa/GargleBlaster/.chef/knife.rb:76:in `load'
    from /Users/rberger/.rvm/gems/ruby-1.9.3-p429/gems/berkshelf-2.0.10/lib/berkshelf/mixin/config.rb:108:in `instance_eval'

The code in berkshelf has defined another "load" method that seems to be in the scope of the code in the knife.rb. So when the knife.rb calls load, its calling the one the berkshelf/mixin/config.

It looks like berkshelf refactored that code in 3.x.beta but I haven't seen if that still has the same problem or not.

@temujin9
Copy link
Contributor

temujin9 commented Oct 9, 2013

You should scope that load call explicitly: I believe its Kernel.load() you
want. That should be backward compatible with 10.x.

Nathaniel Eliot
T9 Productions
On Oct 8, 2013 7:36 PM, "Robert J. Berger" notifications@github.com wrote:

Tried to upgrade to Berkshelf 2.x and found that there is a conflict
between the line in knife/knife.rb:

def load_if_exists(file) ; load(file) if File.exists?(file) ; end

It shows up if you run any berks 2.x commands:

berks --help
/Users/rberger/.rvm/gems/ruby-1.9.3-p429/gems/berkshelf-2.0.10/lib/berkshelf/mixin/config.rb:106:in load': wrong number of arguments (1 for 0) (ArgumentError) from /Users/rberger/work/runa/GargleBlaster/.chef/knife.rb:57:inload_if_exists'
from /Users/rberger/work/runa/GargleBlaster/.chef/knife.rb:76:in load' from /Users/rberger/.rvm/gems/ruby-1.9.3-p429/gems/berkshelf-2.0.10/lib/berkshelf/mixin/config.rb:108:ininstance_eval'

The code in berkshelf has defined another "load" method that seems to be
in the scope of the code in the knife.rb. So when the knife.rb calls load,
its calling the one the berkshelf/mixin/config.

It looks like berkshelf refactored that code in 3.x.beta but I haven't
seen if that still has the same problem or not.


Reply to this email directly or view it on GitHubhttps://github.com//issues/314
.

@westbywest
Copy link

Thanks for the tip about load.rb -> Kernel.load() in knife.rb. That did resolve the "`load': wrong number of arguments (1 for 0)" error Berkshelf v2.x was throwing. What I'm seeing now, trying to run ironfan v6.1.6 with berkshelf v2.0.18, is that every instance of "Chef::Config[...]" in knife-rb and its includes causes berkshelf to throw this error:

$ bundle exec berks version
/Users/mememe/src/ironfan-homebase-v6/.chef/knife.rb:53:in `load': undefined method `[]=' for Berkshelf::Chef::Config:Class (NoMethodError)
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-2.0.18/lib/berkshelf/mixin/config.rb:108:in `instance_eval'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-2.0.18/lib/berkshelf/mixin/config.rb:108:in `load'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-2.0.18/lib/berkshelf/mixin/config.rb:99:in `initialize'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-2.0.18/lib/berkshelf/mixin/config.rb:22:in `new'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-2.0.18/lib/berkshelf/mixin/config.rb:22:in `load'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-2.0.18/lib/berkshelf.rb:60:in `chef_config'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-2.0.18/lib/berkshelf/config.rb:72:in `<class:Config>'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-2.0.18/lib/berkshelf/config.rb:4:in `<module:Berkshelf>'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-2.0.18/lib/berkshelf/config.rb:3:in `<top (required)>'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-2.0.18/lib/berkshelf/cli.rb:2:in `require_relative'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-2.0.18/lib/berkshelf/cli.rb:2:in `<top (required)>'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-2.0.18/lib/berkshelf.rb:129:in `require_relative'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-2.0.18/lib/berkshelf.rb:129:in `<top (required)>'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-2.0.18/bin/berks:3:in `require'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-2.0.18/bin/berks:3:in `<top (required)>'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/bin/berks:23:in `load'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/bin/berks:23:in `<main>'

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

3 participants