RiotGamesCookbooks / rbenv-cookbook

Installs and configures rbenv
http://community.opscode.com/cookbooks/rbenv
Apache License 2.0
137 stars 109 forks source link

Options should be a kind_of String #83

Open jgeiger opened 10 years ago

jgeiger commented 10 years ago

From https://github.com/opscode/chef/blob/master/lib/chef/provider/package/rubygems.rb

Line 369-71: If you have a gem_binary specified, you cannot have options as a Hash.

Line 377-80 If you're using Omnibus, your options should be a String.

Also, there doesn't seem to be any example of how to use options as a hash so it's not clear how to do something like "--force".

caleb commented 10 years ago

I'd love to see this merged. As it is, you can't use the options attribute. If you pass a Hash (as is allowed by this cookbook) it gets shot down by chef, and if you pass a string it is disallowed by this cookbook.

liku commented 10 years ago

+1

ghost commented 10 years ago

Just tried to debug this options thing. Could it be, that options isn't used at all? Or do I just miss where opts gets passed into the install_via_gem_command function? https://github.com/RiotGames/rbenv-cookbook/blob/master/libraries/provider_rbenv_rubygems.rb#L88

jgeiger commented 10 years ago

It's on the end of that line...

"#{gem_binary_path} install #{name} -q --no-rdoc --no-ri #{version_option} #{src}#{opts}"

ghost commented 10 years ago

@jgeiger Yeah, that's where it is used, but how/where is it defined / passed into the function?

jgeiger commented 10 years ago

Likely somewhere higher up the chain. Don't have a lot of time to search but a quick look at https://github.com/opscode/chef/blob/master/lib/chef/provider/package/rubygems.rb

shows it's being used inside the method at 531.

ghost commented 10 years ago

@jgeiger thanks!

jeremyolliver commented 10 years ago

:+1: This is biting me as well. I'm in the unfortunate position of being in an environment needing a proxy. There's no environment option for rbenv_gem, so it kinda hurts that options is unusable as well

caleb commented 10 years ago

Until this is fixed, I've been using this hack in my own rbenv wrapper cookbook:

# Change the rbenv cookbook to make options accept a String or a Hash
Chef::Resource::RbenvGem.send :define_method, :_set_or_return_options do |arg|
   set_or_return(:options, arg, { :kind_of => [String, Hash] })
end
svanharmelen commented 10 years ago

+1

YanhaoYang commented 10 years ago

Yes, this should be merged. I am getting following error:

==> default: ArgumentError
==> default: -------------
==> default: options should be a string instead of a hash
==> default: in rbenv_gem[rake] from /tmp/vagrant-chef-3/chef-solo-1/cookbooks/gco/recipes/default.rb:25:in `from_file'
==> default:
==> default:
==> default: Cookbook Trace:
==> default: ---------------
==> default: /tmp/vagrant-chef-3/chef-solo-1/cookbooks/rbenv/libraries/provider_rbenv_rubygems.rb:64:in `initialize'
==> default:
==> default:
==> default: Resource Declaration:
==> default: ---------------------
==> default: # In /tmp/vagrant-chef-3/chef-solo-1/cookbooks/gco/recipes/default.rb
==> default:
==> default:  25: rbenv_gem "rake" do
==> default:  26:   ruby_version "2.1.2"
==> default:  27:   options force: true
==> default:  28: end
==> default:  29:
jmccann commented 9 years ago

@caleb Does your workaround still work for you in Chef 12.1.0? It seems to work for me in <= 12.0.3 but doesn't in 12.1.0 ...