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

Pocket

何気にユニキャストラボ初登場の箕輪(@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"

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

投稿者紹介

株式会社ユニキャスト
私たちは、テクノロジに魅せられた個性あふれるメンバーによって構成された茨城県日立市に本社を構えるベンチャー企業です。
”テクノロジを通して「驚き」と「感動」を創造し、人々の「夢」と「笑顔」を支えます。” の経営理念をモットーに明るい未来を描き、ワクワクする企画提案を続けて参ります。

コメントを残す

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

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください