Last Updated: February 25, 2016
·
1.627K
· defeated

Careful w/ Rails 4.0.0-beta1 + binstubs

Rails 4.0.0-beta1 has removed the script directory and instead comes with three commands of its own in bin:

  • bin/bundle
  • bin/rails
  • bin/rake

If you run bundle with the --binstubs option, currently it will overwrite the bin/rails and bin/rake files. (This is still an issue in the latest bundler v1.3.1, released today.)

Instead, either use bundle exec <cmd>, or generate a binstub on a case-by-case basis using the new bundle binstubs <gem> command. For example, rspec:

$ bundle binstubs rspec-rails

rspec-rails has no executables, but you may want one from a gem it depends on.
railties has: rails
rspec-core has: autospec, rspec

$ bundle binstubs rspec-core

(Documentation for bundle binstubs is still pending, but you can review the method for yourself.)

Note:

Interestingly enough, the bundle binstubs command does check to see if a file w/ the same name already exists in bin. If we try to rerun bundle binstubs rspec-core we get:

Skipped autospec and rspec since they already exist.
If you want to overwrite skipped stubs, use --force.