14

So i have just swapped over to mac from ubuntu and setting up the env has not been as easy as promised.

this is the process i followed.

  1. installed xcode - then went into the prefrences and downloaded the command line tools
  2. then verified that the right version was installed, by running gcc --version

    i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
    Copyright (C) 2007 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
  3. then installed homebrew $ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
  4. ran brew doctor and this is what i get

    Your system is ready to brew.

5.installed git brew update + brew install git

6.linked my pc to my git account via ssh

7.installed Rbenv

$ brew update
$ brew install rbenv
$ brew install ruby-build

added eval "$(rbenv init -)" to my .bash_profile file

  1. ran rbenv install -list to see all the versions i could install and then ran

    $ rbenv install 1.9.3-p327
    $ rbenv global 1.9.3-p327
    
  2. (i should have rehashed rbenv but i forgot) i then ran gem install bundler

  3. then went into one of my repo's and ran bundle install which blew up with errors

    Gem::InstallError: better_errors requires Ruby version >= 1.9.2.
    An error occurred while installing better_errors (0.7.0), and Bundler cannot continue.
    Make sure that `gem install better_errors -v '0.7.0'` succeeds before bundling.
    

ran ruby -v and saw that it was on 1.8.7 "balls" - i exclaimed

  1. to remedy this i did the following rbenv rehash

  2. ruby -v and got ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin12.3.0] then high fived myself

  3. then tried to run bundle and the same error comes up ??

    $ which bundle
    /usr/bin/bundle
    
    $ which gem
    /Users/fortknokx/.rbenv/shims/gem
    

so this is now where i stand confused as heck. as i said this is my third day using mac and i am pretty new to understanding the $PATH i am sure that i made a foul up somewhere. any advice i am open to.

ps this is what i have in my .bash_profile

export PATH="/usr/local/bin:/usr/local/bin/sublime:~/bin:$PATH"
eval "$(rbenv init -)"
legendary_rob
  • 12,792
  • 11
  • 56
  • 102

2 Answers2

34

The problem seems to be that you're using a system ruby installed bundler, and not one installed with your rbenv ruby.

Run ruby --version to make sure your rbenv ruby is active, then run gem install bundler followed by rbenv rehash and then try reinstalling your gems and see if that works.

lukerandall
  • 2,201
  • 17
  • 29
  • luke your a ninja for sure! – legendary_rob May 03 '13 at 08:12
  • @luke_randall, praise you. – Matt Oct 14 '13 at 21:23
  • 1
    Please clarify how to `make sure your rbenv ruby is active`. Also when I try to run `gem install bundler` I get: `You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.` – James Ward Jan 09 '15 at 18:45
  • @JamesWard if you run `which ruby` from the terminal, it'll give you the path of the ruby binary you're finding. If it's something like `/usr/bin/ruby` it means you're still using your system ruby. Also, your permission error indicates the same thing. You're trying to install a gem systemwide, which requires root access. Test your PATH env var (`echo $PATH` from a terminal) and make sure that you have `/Users/luke/.rbenv/shims` in your path, and that it appears BEFORE `/usr/bin` – lukerandall Jan 11 '15 at 19:24
  • @luke_randall correct me if I'm wrong but I had to run 'rbenv global ruby-version' as well. I was having same permission issue as James. – John Shelley Jun 16 '15 at 21:27
  • 1
    @JohnShelley `rbenv global` sets your default Ruby version. So in the absence of any project-specific (or directory-specific) settings, whatever you set as your global version will be active. So yes, depending on whether you are using this in a directory where you have a Gemfile or .ruby-version file that specifies what Ruby version you'd like to use, you might need to set a global Ruby as well. – lukerandall Jun 18 '15 at 15:22
3

After many installs of rbenv, I too was unsure of why the correct ruby was not being used. Turns out the insertion of the eval statement was prior to the reorganized exports of PATH and the eval failed quietly. Make certain the PATH is established above the eval statement.

nichg
  • 51
  • 2