Wednesday, June 15, 2016

Fighting with Ruby on Rails on old Snow Leopard


Finally I give it a try for Ruby on Rails. The first thing I want to do is install Ruby on Rails. According to the tutorial, I need ruby 1.9.3, then using ruby gem to install rails 2.3.2.

This is not a tutorial, but just show what doesn't works for me. You might not able to get you solution here.

There are a few ways to install Ruby on Rails on Mac OS X:
1. Use Gem on OS X system.
2. Homebrew
3. RVMß (this works for me)

Homebrew

Since then gem version (1.8.7) is a bit too old, I use homebrew to install.
$ brew install ruby
The gem came with ruby, use gem to install rails. Before install rails, I disable ruby document.
$ edit ~/.gemrc
install: --no-rdoc --no-ri
update: --no-rdoc --no-ri
gem: --no-ri
gem: --no-rdoc

$ export GEM_HOME=$HOME/.gems
$ export PATH=$GEM_HOME/bin:$PATH

This suppose to be the way, unfortunately I can't get homebrew to compile ruby on OS X 10.6.

Compile from source

I try to compile from downloaded source, both ruby-2.3.1, ruby-2.3.0 are unable to compile successfully on my OS X 10.6.3. So I compile ruby on another machine with OS X 10.9 Mavericks, and copy the binary to OS X 10.6. The binary can't execute properly.

This really drive me crazy.

I try to use the system gem to install rails, but since the gem version is too old, it can't install the later rails.

RVM, Ruby Version Manager

Try Install ruby on rail with rvm version 1.27.0
$ curl -L https://get.rvm.io | bash -s stable --auto-dotfiles --autolibs=enable --rails
OR just install ruby
$ curl -L https://get.rvm.io | bash -s stable --auto-dotfiles --autolibs=enable --ruby
Ok
Finally the RVM works. The binaries installed in $HOME/.rvm directory

Note:

After some time later, I try to install ruby with homebrew again, and it works! I don't know what changes or configuration I have done.

$ ruby -v
ruby 2.3.1p112
$ gem -v
2.6.4
$ rails -v
4.2.6