So, with Ruby versions coming out so often, well it feels like it. Don’t get me wrong, that is a good thing. The problem is that it requires some testing of existing applications on different versions until it is upgraded. Not only does this apply to Ruby, but also Ruby on Rails as well.

I did my trusty search on Bing! and come across RVM: Ruby Version Manager.

To Install RVM, do the following:

$ gem sources -a http://gemcutter.org/
$ gem install rvm
$ rvm-install
$ echo “if [[ ! -z $HOME/.rvm ]] ; then source $HOME/.rvm ; fi” >> ~/.bash_profile
$ source ~/.rvm/scripts/rvm

Now, you can install the necessary gems, that you want to install. Notice: Also, don’t use sudo as it will mess up the configuration.

Here I install the different Ruby interpreters:

$ rvm install ruby-1.8.7-p160
$ rvm install ruby-1.9.1

Now it’s important to notice that at this point you have separate gem installations for each of the interpreters you’ve installed in the previous step. That said, just go ahead and switch between your interpreters and use your command line scripts – ruby, gem, etc… – as usual.

Now, here is a way to switch between interpreters and install Ruby on Rails versions as well.

$ rvm ruby-1.8.7-p160 #switch to the specified version
$ ruby -v
ruby 1.8.7 (2009-04-08 patchlevel 160) [i686-darwin9.8.0]
$ gem install rails #note I’m not using sudo since the new gem paths point to the user’s home directory

$ rvm ruby-1.9.1 #switch to the specified version
$ ruby -v
ruby 1.9.1p376 (2009-12-07 revision 26041) [i386-darwin9.8.0]
$ gem install rails #note I’m not using sudo since the new gem paths point to the user’s home directory

Okay, you can now switch to a specific interpreter and have multiple rails versions, especially if you are migrating from 2.x to 3.

$ rvm gemset create rails222 rails126
Gemset ‘rails222′ created.
Gemset ‘rails126′ created.

$ rvm 1.9.2-head@rails222
$ gem install rails -v 2.2.2

$ rvm 1.9.2-head@rails126
$ gem install rails -v 1.2.6

There you go, pretty cool!

-Later.

 

After looking around on the Internet, I found a site that provides exactly what I am looking for.
Namely, creating an alias, as I am swapping from different operating systems and still put the wrong commands in.

So, I know how to do an alias, but the step I always forget is to reload my profile settings.

Here is a quick blurb, for those who have not used the command before.

1. First we edit/create a profile. For a normal user do:
pico /etc/profle
…or if you are not a root/superuser do:
pico ~/.profile

2. Add your alias like so to the file:
alias aliasname=’mycommand /path/path’ , I usually put in alias cls=‘clear’ as an example.
(notice no space between equal sign and ‘)

  1. Save your changes and close the file.
  2. Load/reload your profile with:

. /etc/profile
…or if you are not a root/superuser do:
. ~/.profile
*Note: the last file is probably already there as a normal user. Also this is the step I always forget. :-)

  1. If you are using root/sudo you will need to use sudo -i in order to load the profile upon login (more info about this here).

6. Done.

-Later

© 2011 Campbell Gunn Suffusion theme by Sayontan Sinha