David J.
David J.

Reputation: 32705

How to prevent bundler from generating binstubs?

I am using oh-my-zsh with plugins=(git bundler) in my .zshrc. So, I don't need bundler to generate binstubs. But bundler does it anyway.

➜ bundle
Using rake (0.9.2.2) 
...
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
✗ ls bin
erubis       haml         nokogiri     rails        rake2thor    rdoc         resque-web   sass         scss         thor         tt
guard        html2haml    rackup       rake         rdiscount    resque       ri           sass-convert thin         tilt

Why did the binstubs get generated -- I didn't pass an option asking for them. At least, I don't think I am:

➜ which bundle
/Users/david/.rbenv/shims/bundle
➜ cat /Users/david/.rbenv/shims/bundle
#!/usr/bin/env bash
set -e
export RBENV_ROOT="/Users/david/.rbenv"
exec rbenv exec "${0##*/}" "$@"

I don't have anything in my ~/.bundle/config either.

Please help me put the kabosh on the undesired binstubs!

Upvotes: 43

Views: 9170

Answers (3)

User128848244
User128848244

Reputation: 3470

If you are still getting binstubs after changing your $HOME/users/.bundle/config file it is more than likely you have another config some where. In order to figure out where execute the follow command

$ bundle config
Settings are listed in order of priority. The top value will be used.
gem.coc
Set for the current user (/Users/username/.bundle/config): "true"

gem.mit
Set for the current user (/Users/username/.bundle/config): "true"

gem.test
Set for the current user (/Users/username/.bundle/config): "rspec"

build.libv8
Set for the current user (/Users/username/.bundle/config): "--without-system-v8"

disable_multisource
Set for the current user (/Users/username/.bundle/config): "true"

bin
Set for your local app (/Users/username/apps/ruby/rails_application/.bundle/config): "bin"
Set for the current user (/Users/username/.bundle/config): "false"

What you are looking for is the bin information. This information gives you paths to the files that have the config information in them. what you can do in order to fix this is go into config file and delete the line that says BUNDLE_BIN: bin that or change bundle bin to false BUNDLE_BIN: 'false'

vi /Users/username/apps/ruby/rails_application/.bundle/config

If you run bundle config again should not see the bin config or you should see that it is set to false. In this example I set mine to false so I get this new result.

bin
Set for your local app (/Users/username/apps/ruby/gscs_ci/.bundle/config): "false"
Set for the current user (/Users/username/.bundle/config): "false"

Something to note however each ruby application that responds to bundle could have its own custom .bundle/config

If you update all the .bundle/config you should not have new files created in the bin directory when you ruby bundle or bundle install

Found out something else sometimes it thinks false is a directory so might be better to just delete the line that BUNDLE_BIN might be simpler.

Upvotes: 5

iheggie
iheggie

Reputation: 2047

The option --no-binstubs does not remove the remembered option in bundler 1.5.3!

Instead use bundle config --delete bin, or edit .bundle/config and remove the BUNDLE_BIN line from file, then remove unwanted files from the local binstubs directory.

Example:

ianh$ cat .bundle/config 
--- 
BUNDLE_CACHE_ALL: "true"
BUNDLE_BIN: bin

ianh$ bundle install --no-binstubs
Using rake (10.1.1)
... etc etc ...
Using bundler (1.5.3)
Updating files in vendor/cache
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.

ianh$ cat .bundle/config 
--- 
BUNDLE_CACHE_ALL: "true"
BUNDLE_BIN: bin

# see ... it didn't remove the option.

ianh$->(15) bundle config --delete bin

ianh$ cat .bundle/config 
--- 
BUNDLE_CACHE_ALL: "true"

ianh$ bundle -v
Bundler version 1.5.3

Upvotes: 39

indirect
indirect

Reputation: 3490

Bundler generates binstubs on a per-application basis. If you ran bundle install --binstubs at some point in the past, Bundler will remember that and generate binstubs anytime you run install again. To disable them, you can either run bundle install --no-binstubs, or run rm -rf .bundle/config. Either way, that will disable binstub generation.

Upvotes: 96

Related Questions