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

"Option name must be a kind of String!" when installing gems #107

Closed
leifmadsen opened this issue Mar 4, 2015 · 17 comments
Closed

"Option name must be a kind of String!" when installing gems #107

leifmadsen opened this issue Mar 4, 2015 · 17 comments

Comments

@leifmadsen
Copy link

When trying to install a gem, I get this error in Vagrant:

==> web: 
==> web: ================================================================================
==> web: Error executing action `install` on resource 'rbenv_gem[2.1.5::bundler (vagrant)] (vagrant)'
==> web: ================================================================================
==> web: 
==> web: 
==> web: Chef::Exceptions::ValidationFailed
==> web: ----------------------------------
==> web: Option name must be a kind of String!  You passed <rbenv_gem[2.1.5::bundler (vagrant)] (vagrant) @name: "bundler (vagrant)" @noop: nil @before: nil @params: {} @provider: Chef::Provider::Package::RbenvRubygems @allowed_actions: [:nothing, :install, :upgrade, :remove, :purge] @action: :install @updated: false @updated_by_last_action: false @supports: {} @ignore_failure: false @retries: 0 @retry_delay: 2 @source_line: "/tmp/vagrant-chef/8641f98f0aa3af7ee221feb019b1a75e/cookbooks/rbenv/recipes/user.rb:63:in `block (3 levels) in from_file'" @guard_interpreter: nil @default_guard_interpreter: :default @elapsed_time: 0 @sensitive: false @resource_name: :rbenv_gem @declared_type: :rbenv_gem @cookbook_name: :rbenv @recipe_name: "user" @package_name: "bundler" @user: "vagrant" @rbenv_version: "2.1.5" @source: nil @gem_binary: "export RBENV_ROOT=\"/home/vagrant/.rbenv\" && export PATH=\"$RBENV_ROOT/bin:$RBENV_ROOT/shims:$PATH\" && export RBENV_VERSION=\"2.1.5\" && $RBENV_ROOT/shims/gem" @options: nil @root_path: nil @version: "1.8.3" @response_file: nil>.
==> web: 
==> web: 
==> web: Cookbook Trace:
==> web: ---------------
==> web: /tmp/vagrant-chef/8641f98f0aa3af7ee221feb019b1a75e/cookbooks/rbenv/resources/rehash.rb:29:in `initialize'
==> web: /tmp/vagrant-chef/8641f98f0aa3af7ee221feb019b1a75e/cookbooks/rbenv/libraries/chef_provider_package_rbenvrubygems.rb:86:in `new'
==> web: /tmp/vagrant-chef/8641f98f0aa3af7ee221feb019b1a75e/cookbooks/rbenv/libraries/chef_provider_package_rbenvrubygems.rb:86:in `rehash'
==> web: /tmp/vagrant-chef/8641f98f0aa3af7ee221feb019b1a75e/cookbooks/rbenv/libraries/chef_provider_package_rbenvrubygems.rb:67:in `install_package'
==> web: 
==> web: Resource Declaration:
==> web: ---------------------
==> web: # In /tmp/vagrant-chef/8641f98f0aa3af7ee221feb019b1a75e/cookbooks/rbenv/recipes/user.rb
==> web: 
==> web:  63:       rbenv_gem "#{gem['name']} (#{rbenv_user['user']})" do
==> web:  64:         package_name    gem['name']
==> web:  65:         user            rbenv_user['user']
==> web:  66:         root_path       rbenv_user['root_path'] if rbenv_user['root_path']
==> web:  67:         rbenv_version   rubie
==> web:  68: 
==> web:  69:         %w{version action options source}.each do |attr|
==> web:  70:           send(attr, gem[attr]) if gem[attr]
==> web:  71:         end
==> web:  72:       end
==> web:  73:     end
==> web: 
==> web: Compiled Resource:
==> web: ------------------
==> web: # Declared in /tmp/vagrant-chef/8641f98f0aa3af7ee221feb019b1a75e/cookbooks/rbenv/recipes/user.rb:63:in `block (3 levels) in from_file'
==> web: 
==> web: rbenv_gem("bundler (vagrant)") do
==> web:   provider Chef::Provider::Package::RbenvRubygems
==> web:   action :install
==> web:   retries 0
==> web:   retry_delay 2
==> web:   default_guard_interpreter :default
==> web:   declared_type :rbenv_gem
==> web:   cookbook_name :rbenv
==> web:   recipe_name "user"
==> web:   package_name "bundler"
==> web:   user "vagrant"
==> web:   rbenv_version "2.1.5"
==> web:   gem_binary "export RBENV_ROOT=\"/home/vagrant/.rbenv\" && export PATH=\"$RBENV_ROOT/bin:$RBENV_ROOT/shims:$PATH\" && export RBENV_VERSION=\"2.1.5\" && $RBENV_ROOT/shims/gem"
==> web:   version "1.8.3"
==> web: end
==> web: 
==> web: [2015-03-03T20:59:51+00:00] INFO: Running queued delayed notifications before re-raising exception
==> web: [2015-03-03T20:59:51+00:00] ERROR: Converge failed with error message rbenv_gem[2.1.5::bundler (vagrant)] (vagrant) (rbenv::user line 63) had an error: Chef::Exceptions::ValidationFailed: Option name must be a kind of String!  You passed <rbenv_gem[2.1.5::bundler (vagrant)] (vagrant) @name: "bundler (vagrant)" @noop: nil @before: nil @params: {} @provider: Chef::Provider::Package::RbenvRubygems @allowed_actions: [:nothing, :install, :upgrade, :remove, :purge] @action: :install @updated: false @updated_by_last_action: false @supports: {} @ignore_failure: false @retries: 0 @retry_delay: 2 @source_line: "/tmp/vagrant-chef/8641f98f0aa3af7ee221feb019b1a75e/cookbooks/rbenv/recipes/user.rb:63:in `block (3 levels) in from_file'" @guard_interpreter: nil @default_guard_interpreter: :default @elapsed_time: 0 @sensitive: false @resource_name: :rbenv_gem @declared_type: :rbenv_gem @cookbook_name: :rbenv @recipe_name: "user" @package_name: "bundler" @user: "vagrant" @rbenv_version: "2.1.5" @source: nil @gem_binary: "export RBENV_ROOT=\"/home/vagrant/.rbenv\" && export PATH=\"$RBENV_ROOT/bin:$RBENV_ROOT/shims:$PATH\" && export RBENV_VERSION=\"2.1.5\" && $RBENV_ROOT/shims/gem" @options: nil @root_path: nil @version: "1.8.3" @response_file: nil>.

The Vagrantfile contains this section (commented out section of gems causes above issue; runs clean if commented out):

        web.vm.provision :chef_solo do |chef_web|
            chef_web.cookbooks_path = ['chef/cookbooks', 'chef/site-cookbooks']
            chef_web.add_recipe "apt"
            chef_web.add_recipe "nodejs"
            chef_web.add_recipe "ruby_build"
            chef_web.add_recipe "rbenv::user"
            chef_web.add_recipe "vim"

            # Install Ruby 2.1.5 and Bundler
            # Set an empty root password for MySQL to make things simple
            chef_web.json = {
                rbenv: {
                    user_installs: [{
                        user: 'vagrant',
                        rubies: ["2.1.5"],
                        global: "2.1.5",
#                        gems: {
#                            "2.1.5" => [
#                                { 'name' => "bundler" },
#                                { 'name' => "passenger"}
#                            ]
#                        }
                    }]
                },
                mysql: {
                    server_root_password: ''
                }
            }
        end

@oleglitvin
Copy link

We have the same problem.
It seems that something changed in underlying chef provider API since version 12.
You could try to use chef v11.18.6.
It works for us.

@tas50
Copy link
Contributor

tas50 commented Mar 13, 2015

@leifmadsen what version of Chef were you using. I just ran into this on 12.1.1, but didn't see it with 12.0.3. I'm curious what Opscode changed that introduced this behavior.

@bplunkert
Copy link

I am also experiencing this issue with 12.1.1, on ubuntu 14.04, after applying two of the fixes in open PRs here to my fork's master branch.

@tas50
Copy link
Contributor

tas50 commented Mar 15, 2015

I'm fairly certain this issue came about with the 12.1 multi package support changes made in Chef. This cookbook extends the rubygems provider, which was changed extensively with that new feature. I don't run into the issue with Chef 12.03, but I do with 12.1.1

@leifmadsen
Copy link
Author

@tas50 yea I have a plugin on Vagrant that automatically upgrades Chef to the latest client, so it will be a 12.1.x something client.

@lamont-granquist
Copy link

really need the stacktrace

suspect its not the rubygems provider changes but the changes to force the name into a string, but without the full stacktrace all we can do is guess.

@lamont-granquist
Copy link

The name attribute in Chef::Resource also accepts anything that can be #to_s'd to a String now, so its not doing strict validation on that, so without the backtrace the error message makes no sense.

@troyready
Copy link

@lamont-granquist I've got an example that triggers it here.

Here's the end result of a failed chef-client run with it:
https://gist.github.com/troyready/1f4711497fe443096296

Here's the associated stacktrace:
https://gist.github.com/troyready/b732eb4835f53f528dea

I think the chef-client run message shows the offending resource completely, but in case it's helpful here is the definition code that calls the resources (called is this example from another cookbook's recipe named roz to install the gems for a user roz):
https://gist.github.com/troyready/8481b641d98ec37f9efb

@btm
Copy link

btm commented Mar 25, 2015

I poked around a little. Does https://github.com/fnichol/chef-rbenv/blob/master/libraries/chef_provider_package_rbenvrubygems.rb#L86 need to be new_resource.name?

@troyready
Copy link

@btm I think you're right! I tried in in our fork (93f6173) and it worked for me in v12.1 & v12.0

Thanks!

@btm
Copy link

btm commented Mar 25, 2015

@troyready great, thanks. Submitting a PR to update the cookbook for that is probably the easiest fix. I tried something like this, and it works fine:

foo = Chef::Resource::Service.new("foo")
bar = Chef::Resource::Service.new(foo)

Perhaps it's limited to changes in LWRP though. It looks like it was this change: chef/chef@d6d4fd8#diff-135510b4e9e7ac268144bf6a7479a94dL94

Maybe we could do something like name.name if name.kind_of?(Chef::Resource). @lamont-granquist?

@lamont-granquist
Copy link

I still don't understand how it was that change though? The prior behavior was actually much stricter there where passing a Chef::Resource should raise because its not a String so what was happening in 12.0.3 to make it work?

@lamont-granquist
Copy link

And checking for Chef::Resource passed to name of some other resource is pretty immense code smell... That's a huge hack introduced into core chef to work around this one bug.

@lamont-granquist
Copy link

And when that function is hit with a Chef::Resource with the new code we call #to_s on the Resource which would be something of the format file[/tmp/foo] -- incorrect, but its a perfectly fine String.

@troyready
Copy link

FWIW, this cookbook has other issues with Chef v12.0 (e.g. #98/#108), so if this cookbook's current implementation is the only emacs-temperature-rise-user then I think it would be reasonable to just force this cookbook to change.

Just my opinion as one of the people maintaining a fork of it for Chef v12 support.

@lamont-granquist
Copy link

yeah #98/#108 was a deliberate breaking change in 12.0.0, that needs to get fixed here.

looks like this cookbook may need a new maintainer.

john-telford pushed a commit to john-telford/chef-rbenv that referenced this issue Apr 16, 2015
cedricverhaeghe added a commit to cedricverhaeghe/chef-rbenv that referenced this issue Apr 23, 2015
shoyan pushed a commit to shoyan/chef-rbenv that referenced this issue May 20, 2015
kbruner pushed a commit to kbruner/chef-rbenv that referenced this issue May 27, 2015
ianbrown78 added a commit to ianbrown78/chef-rbenv that referenced this issue Jun 4, 2015
ChrisLusted referenced this issue in corewebdesign/chef-rbenv Jun 30, 2015
@lock
Copy link

lock bot commented May 31, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators May 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants