There's an echo in my head

日々のメモ。

capistrano-bundlerでデプロイしたときにbinstubがどうこうという警告が出る件の対応

bundlerでbinstubしたrailsコマンドやrakeコマンドを使っていると、次のような警告がbin/rails cしたときなどに表示される:

Looks like your app's ./bin/rails is a stub that was generated by Bundler.

In Rails 4, your app's bin/ directory contains executables that are versioned
like any other source code, rather than stubs that are generated on demand.

Here's how to upgrade:

  bundle config --delete bin    # Turn off Bundler's stub generator
  rake rails:update:bin         # Use the new Rails 4 executables
  git add bin                   # Add bin/ to source control

You may need to remove bin/ from your .gitignore as well.

When you install a gem whose executable you want to use in your app,
generate it and add it to source control:

  bundle binstubs some-gem-name
  git add bin/new-executable

Loading production environment (Rails 4.1.6)
irb(main):001:0>

ローカルのときは上記の通りrake rails:update:binをすればいい。

capistrano-bundlerを使ってデプロイ先で同じような現象が起こっている場合には https://github.com/capistrano/bundler/issues/45#issuecomment-47428203 より、次のようにconfig/deploy.rbに手を加える。

  • set :bundle_binstubs, nilを加える
  • linked_dirsの中からbinを削除する
このブログに出てくるコードスニペッツは、引用あるいは断りがない限りMITライセンスです。