159

I am hosting on a vps, ubuntu 10.04, rails 3, ruby and mysql installed correctly by following some tutorials. If I run bundle check or bundle install I get the error '-bash: bundle: command not found'. From gem list --local I see 'bundler (1.0.2, 1.0.0)' is installed.

I don't know what's going wrong...

gem environment returns:

 RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.7
  - RUBY VERSION: 1.8.7 (2010-04-19 patchlevel 253) [i686-linux]
  - INSTALLATION DIRECTORY: /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: /opt/ruby-enterprise-1.8.7-2010.02/bin/ruby
  - EXECUTABLE DIRECTORY: /opt/ruby-enterprise-1.8.7-2010.02/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8
     - /root/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

and echo $PATH returns:

/opt/myruby/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/bin/gem:/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/:/root/.gem/ruby/1.8

and which gem returns:

/usr/bin/gem

locate bundle returns:

/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/
1
  • 8
    have you install bundler ?
    – shingara
    Commented Oct 12, 2010 at 13:01

15 Answers 15

219

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

2
  • 3
    rbenv is an alternative to RVM. It manages all your different ruby versions. When you install a gem with gem install it installs it alongside the currently used version of ruby which you can see when you do rbenv versions (it should be marked with a *). When you install the bundler gem, you can bundle install gems which will let you install gems on a per-project basis. The gems you tend to gem install are things like bundler and zeus. When you gem install, you need to run rbenv rehash afterwards. Its just how it is.
    – xxjjnn
    Commented Jul 1, 2014 at 13:27
  • I had this problem on Windows. Rang gem install bundler and it's all good now. Commented Mar 20, 2018 at 20:56
93

You need to add the ruby gem executable directory to your path

export PATH=$PATH:/opt/ruby-enterprise-1.8.7-2010.02/bin
5
  • 15
    Under uBuntu 11.04, the latest command path is now export PATH=$PATH:/var/lib/gems/1.8/bin
    – Antony
    Commented Jul 16, 2011 at 2:13
  • Update: under ubuntu 11.04, it seems the path is irrelevant, because as long as we want to use the latest RubyGem, we just need to install RVM and install desired Ruby version.
    – Antony
    Commented Jul 16, 2011 at 5:58
  • Antony that worked for me and I've submitted an update to the main answer. Commented Sep 7, 2011 at 19:35
  • 5
    For Arch Linux, use export PATH=$PATH:~/.gem/ruby/2.0.0/bin (adjust for your version of Ruby) Commented Aug 1, 2013 at 15:03
  • For rvm use export /usr/local/rvm/gems/ruby-1.9.3-p448/bin:$PATH or ENV PATH /usr/local/rvm/gems/ruby-1.9.3-p448/bin:$PATH with Docker.
    – crizCraig
    Commented Nov 6, 2013 at 23:01
26

... also for Debian GNU/Linux 6.0 :)

export PATH=$PATH:/var/lib/gems/1.8/bin
1
  • Didnt work for me, any suggestions? - GEM PATHS: - /var/lib/gems/1.8 - /kunden/homepages/11/dxxxxxx/htdocs/.gem/ruby/1.8 echo $ PATH ~/.composer/vendor/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/local/ms :/kunden/homepages/11/d3xxxxxx/htdocs/.rvm/bin:/var/lib/gems/1.8/bin:/var/lib/ gems/1.8/bin
    – Juan
    Commented Jan 19, 2016 at 21:15
17

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
0
5

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"
4

For rbenv users:

$ rbenv versions
2.6.0
$ rbenv global 2.6.0
$ ruby -v
ruby 2.6.0p0
$ gem install bundler
$ rbenv rehash
$ bundle
$ rails -v
Command 'rails' not found
$ rbenv rehash
$ rails -v
Rails 4.2.11.1
1
  • key is rbenv rehash
    – ZuBB
    Commented Apr 20, 2023 at 23:52
3

I'm running ubuntu 11.10 and bundle executable was located in:

/var/lib/gems/1.8/bin
3

My solution was to make sure I selected a version of Ruby for that repo.

Example: chruby 2.2.2 or rvm use 2.2.2

λ bundle install
zsh: command not found: bundle

λ ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]

### Notice the system Ruby version isn't included in chruby

λ chruby
  ruby-1.9.3-p551
  ruby-2.1.2
  ruby-2.2.1

### Select a version via your version manager

λ chruby 1.9.3

### Ensure your version manager properly selects a version (*)

λ chruby
 * ruby-1.9.3-p551
   ruby-2.1.2
   ruby-2.2.1

λ bundle install
Fetching gem metadata from https://rubygems.org/.........
3

I got this error rbenv: bundle: command not found after cloning an old rails project I had built a couple on months ago. here is how I went about it: To install a specific version of bundler or just run the following command to install the latest available bundler:

run gem install bundler

then I installed the exact version of bundler I wanted with this command:

$ gem install bundler -v "$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)"

[check this article for more details](https://www.aloucaslabs.com/miniposts/rbenv-bundle-command-not-found#:~:text=When%20you%20get%20the%20rbenv,to%20install%20the%20Bundler%20gem check this article for more details

get the listen to work by issuing this command

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

2

On my Arch Linux install, gems were installed to the ~/.gem/ruby/2.6.0/bin directory if installed as user, or /root/.gem/ruby/2.6.0/bin if installed via sudo. Just append the appropriate one to your $PATH environment variable:

export PATH=$PATH:/home/your_username/.gem/ruby/2.6.0/bin
1

Make sure you do rbenv rehash when installing different rubies

0
1

Step 1:Make sure you are on path actual workspace.For example, workspace/blog $: Step2:Enter the command: gem install bundler. Step 3: You should be all set to bundle install or bundle update by now

0

I think bundle executable is on :

/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/bin and it's not in your $PATH

0

You can also create a symlink:

ln -s /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/bin/bundle /usr/bin/bundle
1
  • ln -s /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/bin/bundle /usr/bin/bundle it should be this with an extra bundle you wanna create sym link to bundle rather than the whole bin dir ? Commented Oct 30, 2015 at 19:03
0

I had the exact same issue and was able to resolve it by running

rbenv rehash

After that bundle worked as expected. Upon taking a look at the rbenv wiki entry it does mention that rehash should be run when an installed gem provides commands.

Installs shims for all Ruby executables known to rbenv (i.e., ~/.rbenv/versions//bin/). Run this command after you install a new version of Ruby, or install a gem that provides commands.

Apparently this is such an annoyance that some folks have written a gem to make sure you never need to run rehash again. rbenv-gem-rehash

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.