Bundler and wrong binstubs?

What worked for me was

rm -rf bin/*

Then open a new terminal session and

bundle exec rake app:update:bin


This error may raise when you update your ruby but not the related gems.

To check if this is your case, try to make a new rails app in a new empty directory (to be sure RVM is not autoloading any gemset)

make /tmp/test && cd test && rails new test

If this fails stating that it cannot find a suitable 'rails', then simply run

gem update

and overwrite any conflicting rails.


gem uninstall bundler
gem install bundler

Uninstalling all my versions of Bundler, and then installing the latest version fixed it for me. I had multiple versions of bundler installed, so when I ran bundle exec rails s I think the wrong Bundler was used, giving me the warning message.

You may need to generate new stubs after reinstalling Bundler, but I didn't have to.


Solution in my case: - Other solutions didn't work for me.


In your Rails directory:

mv /usr/bin/rails /usr/bin/rails.old
bundle config --delete bin
rm -rf bin

# for rails 4.x:
rake rails:update:bin

# for rails 3.x:
bundle install --binstubs

# if you're using rbenv
rbenv rehash
rm -rf ~/.rbenv/plugins/{rbenv-bundle-exec,rbenv-gemset,bundler}

Also be sure that bin/rails is added to the path like:

PATH=./bin:$PATH

Good luck.

Tags:

Ruby

Bundler