capistrano / passenger

Passenger support for Capistrano 3.x
MIT License
138 stars 44 forks source link

undefined method `[]' for nil:NilClass after upgraging Passenger to 5.0.22 #36

Closed zakwanhaj closed 8 years ago

zakwanhaj commented 8 years ago

I received an email from Phusion Passenger team notifying us that a medium severity security vulnerability has been found in Passenger and they recommend to upgrade Passenger to 5.0.22 ASAP.

After I upgraded Passenger to 5.0.22, I couldn't restart Passenger via Capistrano. It keeps getting this error:

SSHKit::Runner::ExecuteError: Exception while executing as deploy@**.**.**.**: undefined method `[]' for nil:NilClass

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

I don't know.. Is it Passenger or Capistrano issue?

For full tracing:

$ cap staging passenger:restart --trace
** Invoke staging (first_time)
** Execute staging
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke rvm:hook (first_time)
** Invoke passenger:rvm:hook (first_time)
** Invoke passenger:test_which_passenger (first_time)
** Execute passenger:test_which_passenger
DEBUG [669d21f4] Running /usr/bin/env which passenger as deploy@**.**.**.**
DEBUG [669d21f4] Command: /usr/bin/env which passenger
DEBUG [669d21f4]    /usr/bin/passenger
DEBUG [669d21f4] Finished in 1.268 seconds with exit status 0 (successful).
** Execute passenger:rvm:hook
** Execute rvm:hook
DEBUG [ae5fa7bb] Running /usr/bin/env [ -d ~/.rvm ] as deploy@**.**.**.**
DEBUG [ae5fa7bb] Command: [ -d ~/.rvm ]
DEBUG [ae5fa7bb] Finished in 0.214 seconds with exit status 1 (failed).
DEBUG [7bcc35da] Running /usr/bin/env [ -d /usr/local/rvm ] as deploy@**.**.**.**
DEBUG [7bcc35da] Command: [ -d /usr/local/rvm ]
DEBUG [7bcc35da] Finished in 0.138 seconds with exit status 0 (successful).
** Invoke rvm:check (first_time)
** Execute rvm:check
DEBUG [947bf3dc] Running /usr/local/rvm/bin/rvm version as deploy@**.**.**.**
DEBUG [947bf3dc] Command: /usr/local/rvm/bin/rvm version
DEBUG [947bf3dc]    rvm 1.26.11 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
DEBUG [947bf3dc]
DEBUG [947bf3dc] Finished in 0.299 seconds with exit status 0 (successful).
rvm 1.26.11 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
DEBUG [c8711a73] Running /usr/local/rvm/bin/rvm current as deploy@**.**.**.**
DEBUG [c8711a73] Command: /usr/local/rvm/bin/rvm current
DEBUG [c8711a73]    ruby-2.2.1
DEBUG [c8711a73]
DEBUG [c8711a73] Finished in 0.293 seconds with exit status 0 (successful).
ruby-2.2.1
DEBUG [a1a529c1] Running /usr/local/rvm/bin/rvm 2.2.1 do ruby --version as deploy@**.**.**.**
DEBUG [a1a529c1] Command: /usr/local/rvm/bin/rvm 2.2.1 do ruby --version
DEBUG [a1a529c1]    ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]
DEBUG [a1a529c1]
DEBUG [a1a529c1] Finished in 0.457 seconds with exit status 0 (successful).
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]
** Invoke bundler:map_bins (first_time)
** Invoke passenger:bundler:hook (first_time)
** Execute passenger:bundler:hook
** Execute bundler:map_bins
** Invoke deploy:set_rails_env (first_time)
** Execute deploy:set_rails_env
** Invoke deploy:set_linked_dirs (first_time)
** Execute deploy:set_linked_dirs
** Invoke passenger:restart (first_time)
** Execute passenger:restart
DEBUG [b7882bc4] Running /usr/bin/env if test ! -d /var/www/project/current; then echo "Directory does not exist '/var/www/project/current'" 1>&2; false; fi as deploy@**.**.**.**
DEBUG [b7882bc4] Command: if test ! -d /var/www/project/current; then echo "Directory does not exist '/var/www/project/current'" 1>&2; false; fi
DEBUG [b7882bc4] Finished in 0.135 seconds with exit status 0 (successful).
DEBUG [0007c29a] Running /usr/bin/env passenger -v as deploy@**.**.**.**
DEBUG [0007c29a] Command: cd /var/www/project/current && /usr/bin/env passenger -v
DEBUG [0007c29a]    Phusion Passenger 5.0.22
DEBUG [0007c29a]
DEBUG [0007c29a] Finished in 0.176 seconds with exit status 0 (successful).
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@**.**.**.**: undefined method `[]' for nil:NilClass
/Users/username/.rvm/gems/ruby-2.2.1/gems/sshkit-1.7.1/lib/sshkit/runners/sequential.rb:24:in `rescue in run_backend'
/Users/username/.rvm/gems/ruby-2.2.1/gems/sshkit-1.7.1/lib/sshkit/runners/sequential.rb:21:in `run_backend'
/Users/username/.rvm/gems/ruby-2.2.1/gems/sshkit-1.7.1/lib/sshkit/runners/sequential.rb:16:in `execute'
/Users/username/.rvm/gems/ruby-2.2.1/gems/sshkit-1.7.1/lib/sshkit/coordinator.rb:21:in `each'
/Users/username/.rvm/gems/ruby-2.2.1/gems/capistrano-3.4.0/lib/capistrano/dsl.rb:55:in `on'
/Users/username/.rvm/gems/ruby-2.2.1/gems/capistrano-passenger-0.1.1/lib/capistrano/tasks/passenger.cap:11:in `block (2 levels) in <top (required)>'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/Users/username/.rvm/gems/ruby-2.2.1/gems/capistrano-3.4.0/lib/capistrano/application.rb:15:in `run'
/Users/username/.rvm/gems/ruby-2.2.1/gems/capistrano-3.4.0/bin/cap:3:in `<top (required)>'
/Users/username/.rvm/gems/ruby-2.2.1/bin/cap:23:in `load'
/Users/username/.rvm/gems/ruby-2.2.1/bin/cap:23:in `<main>'
/Users/username/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval'
/Users/username/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>'
NoMethodError: undefined method `[]' for nil:NilClass
/Users/username/.rvm/gems/ruby-2.2.1/gems/capistrano-passenger-0.1.1/lib/capistrano/tasks/passenger.cap:15:in `block (5 levels) in <top (required)>'
/Users/username/.rvm/gems/ruby-2.2.1/gems/sshkit-1.7.1/lib/sshkit/backends/abstract.rb:77:in `within'
/Users/username/.rvm/gems/ruby-2.2.1/gems/capistrano-passenger-0.1.1/lib/capistrano/tasks/passenger.cap:13:in `block (4 levels) in <top (required)>'
/Users/username/.rvm/gems/ruby-2.2.1/gems/sshkit-1.7.1/lib/sshkit/backends/abstract.rb:85:in `with'
/Users/username/.rvm/gems/ruby-2.2.1/gems/capistrano-passenger-0.1.1/lib/capistrano/tasks/passenger.cap:12:in `block (3 levels) in <top (required)>'
/Users/username/.rvm/gems/ruby-2.2.1/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/Users/username/.rvm/gems/ruby-2.2.1/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:54:in `run'
/Users/username/.rvm/gems/ruby-2.2.1/gems/sshkit-1.7.1/lib/sshkit/runners/sequential.rb:21:in `run_backend'
/Users/username/.rvm/gems/ruby-2.2.1/gems/sshkit-1.7.1/lib/sshkit/runners/sequential.rb:16:in `execute'
/Users/username/.rvm/gems/ruby-2.2.1/gems/sshkit-1.7.1/lib/sshkit/coordinator.rb:21:in `each'
/Users/username/.rvm/gems/ruby-2.2.1/gems/capistrano-3.4.0/lib/capistrano/dsl.rb:55:in `on'
/Users/username/.rvm/gems/ruby-2.2.1/gems/capistrano-passenger-0.1.1/lib/capistrano/tasks/passenger.cap:11:in `block (2 levels) in <top (required)>'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/Users/username/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/Users/username/.rvm/gems/ruby-2.2.1/gems/capistrano-3.4.0/lib/capistrano/application.rb:15:in `run'
/Users/username/.rvm/gems/ruby-2.2.1/gems/capistrano-3.4.0/bin/cap:3:in `<top (required)>'
/Users/username/.rvm/gems/ruby-2.2.1/bin/cap:23:in `load'
/Users/username/.rvm/gems/ruby-2.2.1/bin/cap:23:in `<main>'
/Users/username/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval'
/Users/username/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => passenger:restart
jalberto commented 8 years ago

I have same error, the problem is in this line:

https://github.com/capistrano/passenger/blob/master/lib/capistrano/tasks/passenger.cap#L15

the output for passenger -version doesn't include now 'version" word.

Just senda PR: https://github.com/jalberto/passenger/pull/1

zakwanhaj commented 8 years ago

Thank you @jalberto for your reply. But, there is a little mistake in your regex. You typed: version(? while it should be version)?

zakwanhaj commented 8 years ago

The issue is fixed. Thanks for @jalberto to find the problem. I think this minor change should be added to the gem ASAP.

jalberto commented 8 years ago

thanks for typo hunting :)

betesh commented 8 years ago

35 has been merged. Please update capistrano-passenger to v0.2.0