When you get the rbenv: bundle: command not found error it is most likely the case that you have installed a new Ruby version and you are trying to run a bundle command inside an existing project directory. For every new Ruby version you install, you also need to install the Bundler gem.
As of Ruby 2.6. 0preview3, Bundler is part of core Ruby. You can still install Bundler as a gem, and it basically works.
The bundle exec command ensures that executable programs installed by Gems don't interfere with your app's requirements. For instance, if your app needs a specific version of rake but the default version of rake differs, bundle exec ensures that you can still run the specific rake version compatible with your app.
My problem was that I did:
sudo gem install bundler
So I had installed as root rather than as myself. So I uninstalled as root, then installed as myself:
sudo gem uninstall bundler
gem install bundler
rbenv rehash
(last command for if you are using rbenv)
And it worked. The "correct" path was in .bashrc
(or other shell profile), at least according to
$PATH
=> zsh: /Users/myself/.rbenv/shims:/Users/myself/.rbenv/bin: ... etc
but it was expecting it to be installed for myself - not for root. In my case, its rightful installation place is in ~/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/bundler
You need to add the ruby gem executable directory to your path
export PATH=$PATH:/opt/ruby-enterprise-1.8.7-2010.02/bin
... also for Debian GNU/Linux 6.0 :)
export PATH=$PATH:/var/lib/gems/1.8/bin
I did this (Ubuntu latest as of March 2013 [ I think :) ]):
sudo gem install bundler
Credit goes to Ray Baxter.
If you need gem, I installed Ruby this way (though this is chronically taxing):
mkdir /tmp/ruby && cd /tmp/ruby
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p327.tar.gz
tar xfvz ruby-1.9.3-p327.tar.gz
cd ruby-1.9.3-p327
./configure
make
sudo make install
Probably distro-proof path is adding this to your .bashrc or .zshrc, whatever your shell is :
PATH="$(ruby -e 'print Gem.default_dir')/bin:$PATH"
or if you have installed your gems user-wide, use :
PATH="$(ruby -e 'print Gem.user_dir')/bin:$PATH"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With