Railsアップデート後のCapistranoデプロイ時に、NoMethodErrorが発生する際の対処法

Pocket
LINEで送る

この記事の所要時間: 1226

何気にユニキャストラボ初登場の箕輪(@y_minowa)です。どうぞよろしくお願いします。

さて、先日Railsに深刻な脆弱性が見つかったということで、弊社内のRailsアプリケーションを順次アップデートしています。

Riding Rails: [SEC][ANN] Rails 3.2.11, 3.1.10, 3.0.19, and 2.3.15 have been released!

手順としては、Gemfileに記載されているRailsのバージョンを修正し、

$bundle update

を実行しています。するとCapistranoのバージョンまで上がってしまったのか、デプロイ時にエラーを吐くようになりました。

/var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/recipes/deploy/assets.rb:48:in `block (3 levels) in load': undefined method `shellescape' for :production:Symbol (NoMethodError)
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/configuration/execution.rb:138:in `instance_eval'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/configuration/execution.rb:138:in `invoke_task_directly'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/configuration/callbacks.rb:25:in `invoke_task_directly_with_callbacks'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/configuration/execution.rb:89:in `execute_task'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/configuration/execution.rb:101:in `find_and_execute_task'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/callback.rb:38:in `call'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/configuration/callbacks.rb:141:in `block in trigger'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/configuration/callbacks.rb:141:in `each'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/configuration/callbacks.rb:141:in `trigger'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/configuration/callbacks.rb:27:in `invoke_task_directly_with_callbacks'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/configuration/execution.rb:89:in `execute_task'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/configuration/namespaces.rb:191:in `method_missing'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/configuration/namespaces.rb:110:in `block in define_task'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/recipes/deploy.rb:229:in `block (3 levels) in load'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/configuration/execution.rb:56:in `transaction'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/configuration/namespaces.rb:191:in `method_missing'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/recipes/deploy.rb:228:in `block (2 levels) in load'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/configuration/execution.rb:138:in `instance_eval'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/configuration/execution.rb:138:in `invoke_task_directly'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/configuration/callbacks.rb:25:in `invoke_task_directly_with_callbacks'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/configuration/execution.rb:89:in `execute_task'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/configuration/namespaces.rb:191:in `method_missing'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/configuration/namespaces.rb:110:in `block in define_task'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/recipes/deploy.rb:196:in `block (2 levels) in load'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/configuration/execution.rb:138:in `instance_eval'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/configuration/execution.rb:138:in `invoke_task_directly'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/configuration/callbacks.rb:25:in `invoke_task_directly_with_callbacks'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/configuration/execution.rb:89:in `execute_task'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/configuration/execution.rb:101:in `find_and_execute_task'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/cli/execute.rb:46:in `block in execute_requested_actions'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/cli/execute.rb:45:in `each'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/cli/execute.rb:45:in `execute_requested_actions'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/cli/help.rb:19:in `execute_requested_actions_with_help'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/cli/execute.rb:34:in `execute!'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/lib/capistrano/cli/execute.rb:14:in `execute'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/gems/capistrano-2.14.1/bin/cap:4:in `'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/bin/cap:19:in `load'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/bin/cap:19:in `'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `eval'
	from /var/lib/jenkins/.rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `'

どうやら:productionというシンボルを解釈できなくなっているようです。なので、config/deploy.rb内の、

set :rails_env, :production

の箇所を

set :rails_env, "production"

と修正してデプロイしたら解決できました。少しでも参考になれば幸いです。

投稿者紹介

箕輪 優一
株式会社ユニキャスト 執行役員 大学在学中より勤務し、2012年4月より現職。 「エンジニアの魂を持ったビジネスマンであること」をモットーとして、日々奮闘しています。 / はてなプロフィール - http://www.hatena.ne.jp/yminowa/ / 個人ブログ - http://blog.mino3.com/

人気の記事

コメント

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

PAGE TOP

%d人のブロガーが「いいね」をつけました。