64

I'm using ruby, and I was given a zip file with some ruby programs and it says: inside the folder, run bundle install to install the packages required.

When I run the command in my terminal, it says bundle command not found.

Can someone please give me a detailed description of how I can fix this?

Lukasz Re
  • 79
  • 1
  • 11
ytk
  • 2,787
  • 4
  • 27
  • 42

6 Answers6

128
gem install bundler

is how to do it.

You may want to use a tool such as rbenv to manage gems.

B Seven
  • 44,484
  • 66
  • 240
  • 385
  • 1
    I get the following error when I try that: You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory – ytk Apr 29 '15 at 00:46
  • 3
    Then use `sudo gem install bundler`. – pjs Apr 29 '15 at 00:47
  • 1
    I can swear I tried this earlier and it didn't work. But I just tried it again, and it worked. Haha. Thank you so much! – ytk Apr 29 '15 at 00:50
  • 1
    @TejaK, What worked? `sudo ...`. Don't use sudo for this. Your system has ruby installed for things it does--and you don't want to touch the system install. If you screw up the system install of ruby, you may screw up your whole operating system. You need to install your own ruby to play with. The best(and easiest) way to do that is with rvm(what I use) or rbenv. Yes, you have to install rvm or rbenv first. Once you get your own ruby installed, all you have to do is `gem install bundler`--no sudo. To install rvm, see here: https://rvm.io/rvm/install. – 7stud Apr 29 '15 at 05:36
  • Why is rvm easier than rbenv? – B Seven Apr 29 '15 at 14:00
  • 2
    Yeah all of the other threads also warned against using sudo, so I went ahead and used rbenv as B Seven suggested! – ytk Apr 29 '15 at 19:28
  • Here's a step by step process for setting up `rbenv` and `rbenv-gemset` for a project: http://stackoverflow.com/questions/26575245/how-do-i-ensure-ruby-gems-are-installed-in-right-place-to-be-executed-by-bundler/26575400#26575400 – B Seven Apr 29 '15 at 20:21
  • Absolutely use sudo. – kitti Oct 18 '16 at 17:00
  • @RyanP - No, don't. – B Seven Dec 27 '16 at 17:34
55

Just reiterating that for those (at least on OSX) for whom

gem install bundler

Gives a permissions error, an option that seems to have worked for many people is to use rbenv, which kind of adds a shim between your ruby commands (like gem install) and your environment (if my understanding is correct).

Definitely check out this answer.

The process is laid out fairly well under the above link. I chose to install via homebrew:

brew update
brew install rbenv

Then you have to add an argument command to your profile, which if you're using the common ~/.bash_profile, can be done with:

echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

Which it looks like is adding a command to initialize rbenv via your shell.

Don't for get to start a new shell, possibly by opening a new terminal or using the source ~/.bash_profile command.

Make sure your $PATH has this .rbenv/shims BEFORE any other directory where your shell might be looking for Ruby (OSX comes with it's own version that we don't want to fiddle with): echo $PATH.

which ruby
/Users/mikekilmer/.rbenv/shims/ruby
#GOOD!

Now install a version of Ruby:

rbenv install 2.2.3 

(See all possible versions with rbenv install -l).

Now we can use rbenv global 2.2.3 to switch to a use the newer version of Ruby globally. (Hmm. I thought we didn't want to mess with the system version.) You could also try it with rbenv local 2.2.3 or rbenv shell 2.2.3.

Finally run:

rbenv rehash

Now ruby -v should return 2.2.3 and gem install bundler should work.

Did here.

Community
  • 1
  • 1
MikeiLL
  • 6,282
  • 5
  • 37
  • 68
7

Just run gem install bundler in your terminal.

There is a link to bundler you can take a look:bundler

xcodebuild
  • 1,121
  • 9
  • 17
1

Some ruby version managers like chruby and rbenv store gems separately for each version, so when you install a different version of ruby, you'll need to gem install bundler.

shushugah
  • 180
  • 1
  • 9
1

Tried every solution here but didn't work out. Eventually I got this to work in two different methods:

  • Set alias bundle=/path/to/bundle in .bashrc if you don't care the nastiness.
  • Recreate a fresh dev env via rbenv and do bundle install rails will fix it (fixed my issue).
Stan666
  • 424
  • 2
  • 5
  • 12
-4

Terminal -

sudo su 

then your password:

change directory :

cd command . 

if you do not have permissions to write to drive.

chmod 755 foldername. 

And you can also mkdir command in terminal

mkdir /Library/Ruby/Gems/2.3.0.1

copy and paste: gem install bundler paste to the terminal.

Fetching: bundler-1.16.2.gem (100%)
bundler's executable "bundle" conflicts with /usr/local/bin/bundle
Overwrite the executable? [yN]  y
bundler's executable "bundler" conflicts with /usr/local/bin/bundler
Overwrite the executable? [yN]  y
Successfully installed bundler-1.16.2
Parsing documentation for bundler-1.16.2
Installing ri documentation for bundler-1.16.2
Done installing documentation for bundler after 7 seconds
1 gem installed

works for OS X High Sierra.

NobodyNada
  • 7,529
  • 6
  • 44
  • 51
Anonymous
  • 11
  • 2
  • 1
    1. This is totally unreadable. You should indent commands with 4 spaces. 2. sudo is dangerous. As pointed out above, you are messing with the your systems ruby installation and might break your os. 3. There is lot of unnecessary stuff you do (see accepted answer) – mbuechmann Jun 12 '18 at 14:31