gitorious-cookbooks icon indicating copy to clipboard operation
gitorious-cookbooks copied to clipboard

FATAL: NoMethodError: undefined method `[]' for nil:NilClass

Open frankiejol opened this issue 11 years ago • 6 comments

Hi. I'm trying to install gitorious for debian following this cookbook. This is a debian squeeze. gem -v 1.4.2. I'm taking a look at the .rb files but I don't know where to start.

It fails for me like this:

Recipe Compile Error in /root/chef-solo/cookbooks/gitorious/recipes/default.rb

NoMethodError

undefined method `[]' for nil:NilClass

Cookbook Trace:

/root/chef-solo/cookbooks/apache2/recipes/default.rb:118:in from_file' /root/chef-solo/cookbooks/passenger_apache2/recipes/default.rb:25:infrom_file' /root/chef-solo/cookbooks/passenger_apache2/recipes/mod_rails.rb:25:in from_file' /root/chef-solo/cookbooks/gitorious/recipes/default.rb:1:infrom_file'

Relevant File Content:

/root/chef-solo/cookbooks/apache2/recipes/default.rb:

114: backup false 115: end 116: end 117:
118>> directory "#{node[:apache][:dir]}/ssl" do 119: action :create 120: mode 0755

frankiejol avatar Mar 05 '13 11:03 frankiejol

This is indeed weird because Chef will populate node in this case with this:

https://github.com/rosenfeld/gitorious-cookbooks/blob/master/apache2/attributes/default.rb

I won't have time to test the recipe today but I'll try to give it a try before the end of this week. Have you tried to re-run chef-solo just to make sure it wasn't a temporary problem?

rosenfeld avatar Mar 05 '13 13:03 rosenfeld

Have you tried to re-run chef-solo just to make sure it wasn't a temporary problem? Yes, I did rerun it. In this server I also tried before to install gitorious using this guide http://gitorious.org/gitorious/pages/ObsoleteDebianSqueezeInstallation . I wonder if I left something behind after erasing what I tried.

frankiejol avatar Mar 05 '13 14:03 frankiejol

For reference, I hit the same problem, managed to get round it by adding "recipe[apache2]" to the node.json run_list. Looking at the debug trace from chef-solo it didn't seem to be reading the attributes file for apache2 at all.

Note: I'm a newbie, with absolute zero knowledge of chef, so take my comments with a generous portion of salt.

pgregory avatar Mar 06 '13 08:03 pgregory

Thank you pgreroy, it worked. Now I'm stuck loading the passenger modules in apache. I found two wrong lines , I managed to solve one, but there is another one I don't know how to fix.

/etc/apache2/mods-enabled/passenger.load was missing the mod_passenger.so entry in LoadModule, I found one and it looks it loads. LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.14/ext//apache2/mod_passenger.so

passenger.conf PassengerRoot takes one argument, The Passenger root folder.

PassengerRoot PassengerRuby /usr/bin/ruby1.8 PassengerMaxPoolSize PassengerPoolIdleTime PassengerHighPerformance on

frankiejol avatar Mar 06 '13 09:03 frankiejol

Indeed I can confirm the problem in a new box. Unfortunately it seems something has changed in Chef since I created this recipe but I can't find an easy solution either. I tried to install chef 10.12.0 which I have installed in another box that has worked here but a simple "gem install" won't work in RubyGems 1.4.0 at least. So I installed it via Bundler and it worked but then I got other errors when trying to run chef-solo.

This means I have to look at the documentation for Chef to see what has changed and fix the recipe. Actually I'm not the author of the Apache recipe and it would be probably just a matter of updating it with a newer version available around in several repositories. It is not really important and I'd probably migrate to an nginx approach if I were to work on this recipe again... Also, I'd probably stop using passenger and use Unicorn instead. And I'd also upgrade the recipe to work with the Rails 3 branch.

Those are great changes but I don't currently have time to work on it and I'm not even using Gitorious myself since I changed my job over an year ago. Now I'm the sole developer in the project I maintain and there is no need for such a tool until more developers come aboard... I'd probably also migrate from MySQL to PostgreSQL in the recipe.

If someone wants to send a pull request though I can give it a shot. Or simply fork the project and let me know if you want me to link to your fork in the README.

rosenfeld avatar Mar 06 '13 21:03 rosenfeld

Same issue, but with another cookbook. Does anyone know why the latest Chef version is causing this?

fullofcaffeine avatar Apr 24 '13 04:04 fullofcaffeine