I'm using Chef to set up a node running Ubuntu 12.04. I wanted to use Ruby 1.9.3, including for Chef, and I'm using this custom bootstrap file I found to accomplish it. (I previously tried using RVM in conjunction with Chef, and found that it caused problems at every turn - I was hoping this would be less error-prone.)
When I run the chef-client on this node, it reaches the point of attempting to install my Rails application, tries to install Bundler, and fails, thus:
Recipe: <Dynamically Defined Resource>
* gem_package[Bundler] action install
================================================================================
Error executing action `install` on resource 'gem_package[Bundler]'
================================================================================
NoMethodError
-------------
undefined method `full_name' for nil:NilClass
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/application_ruby/providers/rails.rb
162: gem_package gem do
163: action :install
164: source src if src
165: version ver if ver && ver.length > 0
166: end
167: end
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/application_ruby/providers/rails.rb:162:in `block in install_gems'
gem_package("Bundler") do
provider Chef::Provider::Package::Rubygems
action [:install]
retries 0
retry_delay 2
package_name "Bundler"
version ">1.3"
cookbook_name "tiptap_api"
end
To attempt to isolate the problem, I placed the following call to gem_package
in the recipe before the deployment attempt:
gem_package 'Bundler' do
version '>0'
action :install
end
This, too, fails, in the same way.
I found that the gem
executable installed by apt-get was actually named gem1.9.1
. I thought that this might be the problem, and renamed it to gem
. Once that was done, I could run sudo gem install bundler
normally and without any problems, but the chef-client still produces this error.
What's going on, how can I fix it, and why is this error message so terrible?
From your stack trace, it seems like you want to install a gem called
Bundler
. However, this gem doesn't exist which results in the error you observe. You probably want to install thebundler
gem instead. Case generally matters in the Ruby world :)While it is true that the error message is rather misleading, the reason for that is probably that the case of a non-existing gem is not explicitly checked by Chef and thus assumptions in later stages of the code just break resulting in the strange error.
This in turn might be considered a bug in Chef that you might want to report on http://tickets.opscode.com/ (at least if that still is an issue in the most current version of Chef, I haven't checked that).