Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No bundle shim; rbenv: bundle: command not found #576

Closed
genlighten opened this issue Apr 8, 2014 · 31 comments
Closed

No bundle shim; rbenv: bundle: command not found #576

genlighten opened this issue Apr 8, 2014 · 31 comments

Comments

@genlighten
Copy link

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

@mislav
Copy link
Member

mislav commented Apr 8, 2014

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.

@dinesh-sigmainfo
Copy link

gem install bundler
will resolve this problems

-Sartaj

@hayesgm
Copy link

hayesgm commented Aug 1, 2014

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

@mislav
Copy link
Member

mislav commented Aug 6, 2014

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

@mislav mislav closed this as completed Aug 6, 2014
@gurgelrenan
Copy link

Thanks @sigmainfo, solve my problem here!

@viatcheslavmogilevsky
Copy link

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

@mislav
Copy link
Member

mislav commented Oct 10, 2014

@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).

@viatcheslavmogilevsky
Copy link

Thanks for detailed explanation!

@hanpanpan200
Copy link

solve this problem with: gem install bundler

@noer180895
Copy link

@hanpanpan200 great thanks

@stewartmatheson
Copy link

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.

@mislav
Copy link
Member

mislav commented Jul 26, 2015

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.

@stewartmatheson
Copy link

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.

@amauryce
Copy link

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)

@mislav
Copy link
Member

mislav commented Aug 20, 2015

@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.

@amauryce
Copy link

@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 ?

@gberbert
Copy link

gberbert commented Sep 3, 2015

Hi all its works for me 👍
gem install bundler --no-ri --no-rdoc

@mislav
Copy link
Member

mislav commented Sep 11, 2015

@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.

@FilBot3
Copy link

FilBot3 commented Oct 14, 2015

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.

@levelone
Copy link

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

@mislav
Copy link
Member

mislav commented Oct 29, 2015

@levelone Please try latest version from master branch. bb129a7

brew uninstall rbenv
brew install --HEAD rbenv

@at-binhcq
Copy link

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

@sjreich
Copy link

sjreich commented Jan 9, 2016

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.

@mislav
Copy link
Member

mislav commented Jan 10, 2016

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.

@randonia
Copy link

randonia commented Jan 20, 2016

@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 )

@noer180895
Copy link

long time not use ruby on rails

@duhaime
Copy link

duhaime commented Oct 10, 2016

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

@louisscruz
Copy link

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

@1c7
Copy link

1c7 commented Jul 21, 2019

unset GEM_HOME
gem install bundler

this work for me.

@vitorreis
Copy link

rbenv rehash for the win.

@avonderluft
Copy link

after installing bundler on ruby 1.9.3 with rbenv, I also needed this (rbenv rehash didn't cut it):
ln -s ~/.gem/ruby/1.9.1/bin/bundle ~/.rbenv/versions/1.9.3-p551/bin/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests