Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bundler and wrong binstubs?

Tags:

ruby

bundler

I run rails s or bundle exec rails s and I get this warning:

Bundler is using a binstub that was created for a different gem. This is deprecated, in future versions you may need to `bundle binstub rails` to work around a system/bundle conflict. 

What does this mean? From looking around the bundler site, my understanding of binstubs is that you can set executables to them, so instead of running bundle exec blabla you can just do bin/blabla. So this error is saying my bundler isn't set to the right binstub?

When I run the bundle binstub rails I get this output

rails has no executables, but you may want one from a gem it depends on.   railties has: rails   bundler has: bundle, bundler 

I do not understand what my system is trying to tell me, and it's not breaking anything, but I have a hunch this could turn into a bigger issue if I don't fix it

ruby 2.0.0p247 

which ruby

/Users/evan/.rvm/rubies/ruby-2.0.0-p247/bin/ruby 

which bundler

/Users/evan/.rvm/gems/ruby-2.0.0-p247/bin/bundler 

Rails 4.0.2

Edit:

So, if I run the commands in the nag message:

  bundle config --delete bin    # Turn off Bundler's stub generator   rake rails:update:bin         # Use the new Rails 4 executables 

I end up getting uninitialized constant Bundler errors with bundle exec commands and the only way I've found to fix that is to rerun bundle install --binstubs which brings back the nag message at the start of this post.

like image 364
user2936314 Avatar asked Apr 19 '14 04:04

user2936314


People also ask

What is Bundler binstubs?

Binstubs are a shortcut-or alternative- to always using bundle exec . This gives you a file that can be run directly, and one that will always run the correct gem version used by the application. For example, if you run bundle binstubs rspec-core , Bundler will create the file bin/rspec .

How do you remove Binstubs?

To disable them, you can either run bundle install --no-binstubs , or run rm -rf . bundle/config . Either way, that will disable binstub generation.

What are Rails binstubs?

Binstubs are wrapper scripts around executables (sometimes referred to as "binaries", although they don't have to be compiled) whose purpose is to prepare the environment before dispatching the call to the original executable.

Should be used instead of the bundler generated rails Binstub?

Beginning in Rails 4, Rails ships with a rails binstub at ./bin/rails that should be used instead of the Bundler-generated rails binstub. So, at the end of the day there's no difference. But considering the fact that Rails goes through the trouble of shipping its own binstubs, I'd favor bin/rails alternative.


1 Answers

What worked for me was

rm -rf bin/*

Then open a new terminal session and

bundle exec rake app:update:bin

like image 147
Ju Liu Avatar answered Sep 19 '22 05:09

Ju Liu