capistrano / rvm

MIT License
140 stars 47 forks source link

rvm.rake:9: undefined method `include?' for nil:NilClass #4

Closed MiguelPF closed 11 years ago

MiguelPF commented 11 years ago

This line is causing me trouble: if fetch(:rvm_map_bins).include?(key.to_s)

Is it possible that this code should check the existence of rvm_map_bins before calling include?

leehambley commented 11 years ago

This like should always exist, unless you are loading things in a strange order, as far as I know?

MiguelPF commented 11 years ago

I think I am using the standard order: require 'capistrano/setup'

require 'capistrano/deploy' require 'capistrano/rvm' require 'capistrano/bundler'

I hack it with set :rvm_map_bins, []

leehambley commented 11 years ago

I didn't write the rvm integration, it was contributed by a 3rd party, so I hope they pick this issue up and can comment on whether this is expected.

Kriechi commented 11 years ago

the rvm_map_bins should be set to the correct value in the load:defaults task, which is executed prior every deploy-task. Please try and run cap production deploy -t and check which tasks are executed in which order. It should look somethink like this:

** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke deploy (first_time)
** Execute deploy
** Invoke deploy:starting (first_time)
** Invoke deploy:ensure_stage (first_time)
** Execute deploy:ensure_stage
** Invoke deploy:set_shared_assets (first_time)
** Execute deploy:set_shared_assets
** Execute deploy:starting
** Invoke deploy:check (first_time)
** Execute deploy:check
** Invoke git:check (first_time)
** Invoke git:wrapper (first_time)
** Execute git:wrapper
MiguelPF commented 11 years ago

yes here it's my output: * Invoke production (first_time) * Execute production * Invoke deploy (first_time) * Execute deploy * Invoke deploy:starting (first_time) * Invoke deploy:ensure_stage (first_time) * Execute deploy:ensure_stage * Execute deploy:starting * Invoke deploy:check (first_time) * Execute deploy:check * Invoke git:check (first_time) * Invoke git:wrapper (first_time) \ Execute git:wrapper

I guess this bug should be in capistrano page then, right? Thank you

Kriechi commented 11 years ago

I think so, yes. It seems that the load:default task is not executed in your setup. Also I've noticed that the dry-run option for capistranor produced an error - also a bug not releated to this rvm plugin.

Just to be sure: you did specify the git-repository in your gemfile? Because the current gem version on rubygems is pretty old and has barley nothing to do with the current one right here.

MiguelPF commented 11 years ago

Yes, thank you, that was exactly my problem, I had the github version of capistrano/rvm but the rubygems version of capistrano, after changing the capistrano version to github repo v3 all went well

contentfree commented 11 years ago

I'm getting this same issue.

Relevant parts of Gemfile:

group :development do
  gem 'capistrano', github: 'capistrano/capistrano'
  gem 'capistrano-rails'
  gem 'capistrano-bundler'
  gem 'capistrano-rvm', github: 'capistrano/rvm'
end

Top of cap config.rb:

require 'capistrano/bundler'
require 'capistrano/rvm'       # Tried this above bundler too to no effect
require 'capistrano/rails'

Generates this error:

$ cap production rvm:check -t
** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke rvm:check (first_time)
** Invoke rvm:hook (first_time)
** Execute rvm:hook
** Invoke rvm:init (first_time)
** Execute rvm:init
cap aborted!
undefined method `include?' for nil:NilClass
/Users/dave/.rvm/gems/ruby-2.0.0-p247/gems/capistrano-rvm-0.0.2/lib/capistrano/tasks/rvm.rake:9:in `block in <top (required)>'
/Users/dave/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/command.rb:201:in `yield'
/Users/dave/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/command.rb:201:in `to_s'
/Users/dave/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/formatters/pretty.rb:24:in `String'
/Users/dave/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/formatters/pretty.rb:24:in `write_command'
/Users/dave/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/formatters/pretty.rb:12:in `write'
/Users/dave/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:107:in `block in _execute'
/Users/dave/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:106:in `tap'
/Users/dave/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:106:in `_execute'
/Users/dave/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:64:in `capture'
/Users/dave/.rvm/gems/ruby-2.0.0-p247/gems/capistrano-rvm-0.0.2/lib/capistrano/tasks/rvm.rake:61:in `block (3 levels) in <top (required)>'
/Users/dave/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:42:in `instance_exec'
/Users/dave/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:42:in `run'
/Users/dave/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => rvm:init

load:defaults appears to be running, but it appears rvm_map_bins is still missing...

contentfree commented 11 years ago

I had to manually add the following to my config.rb (which is strange because I can plainly see where rvm.rake sets them in the load:defaults task):

set :rvm_map_bins, %w{bundle gem rake ruby}
set :rvm_type, :auto
contentfree commented 11 years ago

Maybe there's a problem with load:defaults? (Seems impossible, but I believe I'm seeing problems loading defaults from capistrano/bundler too)

kirs commented 11 years ago

It may be somehow connected with https://github.com/capistrano/capistrano/issues/640 @seenmyfate any ideas?

contentfree commented 11 years ago

Well, mine might be a case of the Idiots or it might be an important distinction to make:

To get things to work, I had to require 'capistrano/bundler' etc in Capfile and not config/deploy.rb

I believe this is related to capistrano/capistrano#640 in some way though it might just be a trade-off. load:defaults is invoked before config/deploy.rb is loaded so requireing bundler and rvm there means their load:defaults tasks never run.