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.
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.