RVM Ruby Install on Lion Got You Down?

After a fresh install of OSX Lion, RVM decided no more of my ruby friends could come over and play. So I was all like “what’s up, RVM… y u no like my ruby exchange students anymore?”

Turns out Lion made some changes to what default compiler is getting used which makes building ruby via RVM unhappy. After some searching, the fine folks over at StackOverflow are full of win again.

Here is the solution that works for me:

CC=/usr/local/bin/gcc-4.2 rvm install <ruby version>

It was recommended that the CC variable declaration could be put in your profile reducing the need to enter it every time, but I’m uncomfortable just blindly making that change. If this is the only time I need to do this, I think I’m OK with it.

QuickCast - RVM Global Gemset

Getting a new Ruby version set up for development can be a pain. Yeah I hear you, not as much as it used to be… of course! Now we have the magic and wonder of RVM.

Well I would like to share this little tidbit that should make getting your environment up and running even faster. Global Gemsets… This allows you to declare gems that you always want to have installed. Once that is set up, after a new ruby is installed it will install those gems as well.

This is my first screencast so please critique so the next episodes can be even better!

Which RVM gemset am I on?

So jumping back and forth around the command line on different projects has made me constantly double check where I am at. Mostly because I’ve fallen a few times to the ‘oops, I installed that gem in the wrong gemset’ conundrum. Usually that is not a problem unless you’re working with some gems that have to build to the system. Anyway, I decided to solve this problem!

Inspired by this article, I’ve modified my command prompt so that the ruby version and gemset you are currently working on is displayed. I haven’t seen many people do this and was surprised to even find the article on how to set it up. So kudos to that guy.

I find it extremely useful and hopefully you will too. Just add this function into your bash profile:

function rvm_version { 
  local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}') 
  [ "$gemset" != "" ] && gemset="@$gemset" 
  local ruby_version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}') 
  [ "$ruby_version" != "" ] && ruby_version="$ruby_version" 
  local full="$ruby_version$gemset" 
  [ "$full" != "" ] && echo "$full " 
} 

And then activate it by adding to the PS1 variable. (I just added it to the front of mine. I’ve removed the rest of the mess that is my PS1 for simplicity)

export PS1='$(rvm_version) \w'

Boom… ruby version and gemset info straight to your face!

UPDATE: It was brought to my attention that the command rvm-prompt will return exactly the ruby and gemset you are using. I did not know about this and seems way cool. You can add it right into your prompt like so:

export PS1='$(rvm-prompt) \w'

It can get a little long depending on the ruby/gemset combo you are sporting.. but useful info I think.

rvm