bundler: Don't generate binstubs by default when using Rails 4?

When using Rails 4, the default options result in this error being raised when running a command from bin in a deployed environment:

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

I have in fact checked in a bin with executables generated by Rails, but they are not used, because by default bin is symlinked to shared/bin, containing executables with bundler-generated executables. Of course it is trivial to configure bundler such that this doesn’t happen, but since everyone using Rails 4 needs to do that, it would be better to just do ‘the right thing’ out of the box.

Do you agree and are you interested in a pull request for this?

Edit: Also see https://github.com/rails/rails/issues/8974 and specifically https://github.com/rails/rails/issues/8974#issuecomment-22993215

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Reactions: 4
  • Comments: 43 (8 by maintainers)

Commits related to this issue

Most upvoted comments

My solution for now… In config/deploy.rb file:

  • add line set :bundle_binstubs, nil
  • remove bin from linked dirs set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}