Instantly share code, notes, and snippets.

Embed
What would you like to do?
Installing Ruby 1.9.3 with rbenv on OS X
# The latest version of this script is now available at
# https://github.com/jasoncodes/dotfiles/blob/master/aliases/rbenv.sh
VERSION=1.9.3-p286
brew update
brew install rbenv ruby-build rbenv-vars readline ctags
if [ -n "${ZSH_VERSION:-}" ]; then
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.zshrc
else
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.bash_profile
fi
eval "$(rbenv init - --no-rehash)" # load rbenv in the current shell
CONFIGURE_OPTS="--disable-install-doc --with-readline-dir=$(brew --prefix readline)" rbenv install $VERSION
rbenv global $VERSION
gem install --no-ri --no-rdoc bundler rbenv-rehash git-up hitch gem-browse gem-ctags cheat awesome_print pry
gem ctags
@twe4ked

This comment has been minimized.

twe4ked commented Sep 17, 2011

Is this you leaving RVM behind?

@jasoncodes

This comment has been minimized.

Owner

jasoncodes commented Sep 17, 2011

Quite possibly, I'm giving rbenv a serious go. All good so far.

@SethWilson

This comment has been minimized.

SethWilson commented Oct 11, 2011

Thanks a million for this. Fixed a problem I was having with readline on Lion

@nielsenrechia

This comment has been minimized.

nielsenrechia commented Jul 7, 2012

Hi I can't install ruby 1.9.3-p194 yet. I did all steps above but always I had this warning ruby-build: definition not found: 1.9.3-p194, what can be? thenks

@jasoncodes

This comment has been minimized.

Owner

jasoncodes commented Jul 7, 2012

@nielsenrechia It sounds like you need a later version of ruby-build. You may need to update your Homebrew install with brew update.

@nielsenrechia

This comment has been minimized.

nielsenrechia commented Jul 7, 2012

I did it but it is already up to date :(

@jasoncodes

This comment has been minimized.

Owner

jasoncodes commented Jul 7, 2012

@nielsenrechia And you reinstalled ruby-build after any update? I have 20120524 here and ruby-build --definitions shows 1.9.3-p194. You could try brew install https://raw.github.com/mxcl/homebrew/master/Library/Formula/ruby-build.rb.

@nielsenrechia

This comment has been minimized.

nielsenrechia commented Jul 7, 2012

I have the same 20120524 but does not show to me 1.9.3-p194, I tried brew install https://raw.github.com/mxcl/homebrew/master/Library/Formula/ruby-build.rb but shows to me Error: ruby-build-20120524 already installed
I don't know why :(

@jasoncodes

This comment has been minimized.

Owner

jasoncodes commented Jul 7, 2012

@nielsenrechia You'd need to brew uninstall ruby-build first. If that doesn't work after that, there's probably something peculiar going on with your setup. Check out brew doctor as well.

@nielsenrechia

This comment has been minimized.

nielsenrechia commented Jul 7, 2012

So, tried brew doctor as you told me, it shows me that:

Error: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built.

ruby-build

Error: Your compilers are different from the standard versions for your Xcode.
If you have Xcode 4.3 or newer, you should install the Command Line Tools for
Xcode from within Xcode's Download preferences.
Otherwise, you should reinstall Xcode.
Error: /usr/bin occurs before /usr/local/bin
This means that system-provided programs will be used instead of those
provided by Homebrew. The following tools exist at both paths:

clusterdb
createdb
createlang
createuser
ctags
dropdb
droplang
dropuser
ecpg
pg_config
pg_dump
pg_dumpall
pg_restore
pg_upgrade
psql
reindexdb
vacuumdb

I don't know what to do, sincerely

@jasoncodes

This comment has been minimized.

Owner

jasoncodes commented Jul 7, 2012

@nielsenrechia brew link ruby-build should fix the unlinked keg although this should also have been resolved by uninstalling and reinstalling ruby-build. You're probably also going to have to follow those Xcode instructions as well to get Ruby compiling properly.

@nielsenrechia

This comment has been minimized.

nielsenrechia commented Jul 7, 2012

Hy man, I finished it, now i'm using ruby 1.9.3 correctly, but my terminal when open always sets down and I have to put it exe c $SHELL, So when I close the terminal and reopen it, I need to put exec $SHELL again to sets it up. I don't know if you will understand me

@jasoncodes

This comment has been minimized.

Owner

jasoncodes commented Jul 8, 2012

@nielsenrechia exec $SHELL reloads your current shell and it generally should do roughly the same thing as opening a new terminal. Perhaps these two things are loading different configuration files. Try adding the rbenv init line that is now at the bottom of your ~/.bash_profile to your ~/.bashrc as well.

@nathanaelkane

This comment has been minimized.

nathanaelkane commented Sep 15, 2012

To install older versions of Ruby (e.g. 1.9.2), I first had to install the official GCC compiler: https://github.com/kennethreitz/osx-gcc-installer/downloads

@timoxley

This comment has been minimized.

timoxley commented Nov 5, 2012

You should prolly add brew update to the start of the list of commands.

@timoxley

This comment has been minimized.

timoxley commented Nov 5, 2012

and this could be more sexy-like: brew install rbenv ruby-build rbenv-vars readline ctags

@jasoncodes

This comment has been minimized.

Owner

jasoncodes commented Nov 6, 2012

@timoxley Cheers. Updated.

@TonyJHopkinson

This comment has been minimized.

TonyJHopkinson commented May 28, 2013

Thank you. Scratching my head for a while. No one else mentioned rbenv-vars.

@snowleung

This comment has been minimized.

snowleung commented Aug 30, 2013

helpful! thank you. i use "brew install rbenv ruby-build rbenv-vars readline ctags" and "rbenv -global xxx" fix my upgrade ,do you know why i use rbenv upgrade it but still at old version? anyway , it's work! thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment