Rbenv: No bundle shim; rbenv: bundle: command not found

Created on 8 Apr 2014  Â·  30Comments  Â·  Source: rbenv/rbenv

I'm trying to install rbenv on a machine that previously had rvm installed. I've followed the various instructions to remove all vestiges of rvm. But I have the following problems, which I assume are related:

1) Trying to install nokogiri 1.6.0 gives an error indicating the bundle command can't find the ruby 1.9.2 version that rbenv says is the current one.

2) There is no 'bundle' shim in ~/.rbenv/shims

3) which bundle gives /usr/bin/bundle

4) rbenv which bundle gives rbenv: bundle: command not found

I've removed /usr/bin from my path as mentioned in a similar issue elsewhere here. Do I need to uninstall and reinstall bundler?

Any and all help or guidance would be greatly appreciated.

Thanks!

Dean Richardson

Most helpful comment

gem install bundler
will resolve this problems

-Sartaj

All 30 comments

Having /usr/bin/bundle means that Bundler is installed in your system Ruby (/usr/bin/ruby). That's not necessarily a problem, but you don't want to use that Bundler; you want to use the Bundler installed in your local Ruby version managed by rbenv.

Because ~/.rbenv/shims/bundle doesn't exist, I would guess that your local version of Ruby either doesn't have Bundler installed, or you haven't run rbenv rehash after installing Bundler. Check these things:

  • gem env - verify that you're using RubyGems inside your location version of Ruby for this project, not the system version
  • gem list bundler - it should be installed. If not, install it.
  • rbenv rehash - This should be run after every gem install. You can install the rbenv-gem-rehash plugin to avoid having to do this step all the time.

gem install bundler
will resolve this problems

-Sartaj

+1 for gem install bundler --no-ri --no-rdoc

@genlighten I'm closing this since I hope this information was enough for you to resolve your issue in the meantime.

Thanks @sigmainfo, solve my problem here!

I have issued 'rbenv rehash' after installing bundle gem ( gem install bundler )

And I have bundle gem:

$ gem list bundler
*** LOCAL GEMS ***
bundler (1.7.3)

But I still do not have bundle executable in rbenv shims

$ rbenv which bundle
rbenv: bundle: command not found

Thus, I can not issue bundle:

$ bundle exec rails c
The program 'bundle' is currently not installed. You can install it by typing

This is my output from gem env:

RubyGems Environment:
  - RUBYGEMS VERSION: 2.2.2
  - RUBY VERSION: 2.1.2 (2014-05-08 patchlevel 95) [x86_64-linux]
  - INSTALLATION DIRECTORY: /home/ubuntu/.gem
  - RUBY EXECUTABLE: /home/ubuntu/.rbenv/versions/2.1.2/bin/ruby
  - EXECUTABLE DIRECTORY: /home/ubuntu/.gem/bin
  - SPEC CACHE DIRECTORY: /home/ubuntu/.gem/specs
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /home/ubuntu/.gem
     - /home/ubuntu/.gem/ruby/2.1.0
     - /home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - :sources => ["https://rubygems.org"]
     - "gem" => "--no-ri --no-rdoc"
  - REMOTE SOURCES:
     - https://rubygems.org
  - SHELL PATH:
     - /home/ubuntu/.rbenv/versions/2.1.2/bin
     - /home/ubuntu/.rbenv/libexec
     - /home/ubuntu/.rbenv/plugins/rbenv-sudo/bin
     - /home/ubuntu/.rbenv/plugins/rbenv-use/bin
     - /home/ubuntu/.rbenv/plugins/ruby-build/bin
     - /bin
     - /home/ubuntu/.rbenv/shims
     - /home/ubuntu/.rbenv/bin
     - /usr/local/sbin
     - /usr/local/bin
     - /usr/sbin
     - /usr/bin
     - /sbin
     - /bin
     - /usr/games
     - /usr/local/games

@viatcheslavmogilevsky This is because your environment is configured to install gems in the home directory location of ~/.gem, probably by setting GEM_HOME and GEM_PATH to that location or by having similar ~/.gemrc or /etc/gemrc settings.

rbenv doesn't work well with the user install location since it's hard for it to pick up executables from there. You could try my experimental plugin for this case, run rbenv rehash after that and see if it solves your problem. Or, you could install Bundler again in the "system" location (~/.rbenv/versions/2.1.2/lib/ruby/gems).

Thanks for detailed explanation!

solve this problem with: gem install bundler

@hanpanpan200 great thanks

Hey @mislav. Great work on rbenv! From what I have noticed it looks like if you already have bundler installed in the system gem set then rbenv will not create the bundle shim.

I set my ruby version using rbenv and then run jgem install bundler bundler will be installed to that selected ruby's gemset. This I expected. The issue came when I ran rbenv rehash. The bundler version was still set to the system gem set bundler, not the bundler I had just installed. I looked in the shims directory and I could not find a bundle shim. Is that a bug? I would have expected rbenv to create a bundle shim after rehashing so I can use the version of bundler I had just installed.

The problem seems to be that the bundle shim isn't getting installed by rbenv rehash. Can you check rbenv whence bundle? It should list the Ruby versions managed by rbenv which have the bundle executable within.

OK so the issue is different to what I thought it was but I have tracked it down. It seems that rbenv does not handle the gem shim correctly with jruby. With jruby selected by rbenv running jgem returns a list of gems installed under that version of jruby. Running gem returns a list of gems installed by system ruby. I would expect both gem and jgem to return the same gemset when a jruby version is selected by rbenv.

Running whence on gem and jgem both yield the jruby version I have selected but this does not seem to be the case during execution.

hi,
when I run gem install bundler
I get : /Users/nouveau/.rbenv/shims/gem: ligne21: /usr/local/Cellar/rbenv/0.4.0/libexec/rbenv: No such file or directory

Does anyone know how to solve this issue ?
(NB: I m trying to re-install Homebrew that didn't run because of that issue, and that I broke running rm -rf /usr/local/Cellar)

@amauryce Your problem is because you've installed rbenv using Homebrew, but since then you've removed Homebrew, breaking the rbenv install.

I suggest that you reinstall rbenv from Homebrew and then run rbenv rehash.

@mislav thank you for your answer

I 'reinstalled' /usr/local/Cellar (I just copy/paste from another configuration)
I know have :
➜ comint git:(master) rbenv rehash
rbenv: no such command `rehash'

It sounds that I broke the dependancies of my application :
➜ comint git:(master) rails c
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.

➜ comint git:(master) bundle install
ERROR: RVM Ruby not used, run rvm use 2.0.0 first.

➜ comint git:(master) cap production deploy
zsh: command not found: cap

But 'rails s' works fine.

Do you have an idea ?

Hi all its works for me :+1:
gem install bundler --no-ri --no-rdoc

@amauryce You seem to be using RVM, which is a Ruby version manager completely different and incompatible with rbenv. We can't provide support if you have problems with RVM.

What I had to do to fix this issue for me was, make sure I had rbenv global <version> ran, and all the other .bash_profile settings recommended on the README setup. Then reinstall the gem, and now when I do rbenv which bundler it actually shows the correct directory.

Currently have an issue when i try to bundle install. The results continue in a loop and says the stack level issues.

This is the error I get:
/usr/local/Cellar/rbenv/HEAD/rbenv.d/exec/gem-rehash/rubygems_plugin.rb:27:in `install'

I've tried rehashing, reinstalling bundler. Currently on:
ruby -v 2.2.0 # rbenv
bundler -v 1.10.6

@levelone Please try latest version from master branch. bb129a782be82a671bc3bd2ae2d42dbed01e84b6

brew uninstall rbenv
brew install --HEAD rbenv

+1 for gem install bundler --no-ri --no-rdoc

For the record:

I was having an issue where bundle install installed gems to one place, but bundle exec looked for them in a different place.
$ bundle show diff-lcs returned /Library/Ruby/Gems/2.0.0/gems/diff-lcs-1.2.5, while
$ gem env produced
- INSTALLATION DIRECTORY: /Users/jreich/.rbenv/versions/2.0.0-p648/lib/ruby/gems/2.0.0, among other things.

I solved this issue by running the commands give above:
brew uninstall rbenv
brew install --HEAD rbenv.

Note that brew install --HEAD rbenv is no longer necessary after the 1.0.0 release. Simply brew install rbenv will do and will allow the formula to be updated in the future with brew upgrade rbenv.

@mislav I had GEM_HOME defined and using an older version of Ruby through rbenv (2.1.5) made bundler cease working. Spent the better part of an hour debugging, wound up here on your comment about GEM_HOME causing problems. unset GEM_HOME and viola, gem install bundler installed to the correct ~/.rbenv/shims location and then bundle worked.

Note that there was no problem before since my system installation of bundle matched the rbenv version requirement, so it never caused any issues.

[edit] gem install bundle -> gem install bundler (thanks @louisscruz )

long time not use ruby on rails

I hit this same wall today and I needed to set both my local and my global rbenv values to my project's .ruby-version value to be able to run:

gem install bundler
bundle install

The answer provided by @randonia worked for me! But there's a typo. Just run unset GEM_HOME, then gem install bundler. Thanks @randonia!

unset GEM_HOME
gem install bundler

this work for me.

rbenv rehash for the win.

Was this page helpful?
0 / 5 - 0 ratings