Monthly Archives: October 2011

Use Ruby 1.9.2 on Lion

The process for installing Ruby 1.9.2 on Mac Lion + IDE is as follows:


# 1. Could have used homebrew. But, MacPort still works. And, RVM does not play nice with Netbeans 6.9.1
#install rubygems for 1.9 is already included in this port, no need to do a separate install.

sudo port install ruby19

#2. Change the symbolic links

cd /opt/local/bin

sudo ln -s erb1.9 erb
sudo ln -s gem1.9 gem
sudo ln -s irb1.9 irb
sudo ln -s rake1.9 rake
sudo ln -s rdoc1.9 rdoc
sudo ln -s ri1.9 ri
sudo ln -s ruby1.9 ruby
sudo ln -s testrb1.9 testrb

#3. Add /opt/local/bin in front of the $PATH in .bash_profile file

# MacPorts Installer addition on 2011-05-08_at_20:54:13: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH

# 4. install gems

sudo gem install rails

# 5. install debuggers

sudo gem install ruby-debug19
sudo gem install ruby-debug-ide19
sudo gem install linecache19

# 6. fix the defect in the ruby-debug-0.4.12  per http://noteslog.com/post/netbeans-6-9-1-ruby-1-9-2-rails-3-0-0-debugging/

The detailed instruction for fixing the gem is here. Recap as follows

line 142 (optional error) /opt/local/lib/ruby1.9/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug-ide.rb


# error line: $stderr.printf "Fast Debugger (ruby-debug-ide 0.4.9) listens on #{host}:#{port}\n"

$stderr.printf "Fast Debugger (ruby-debug-ide19 0.4.12) listens on #{host}:#{port}\n"

line 78 (serious error) /opt/local/lib/ruby1.9/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/bin/rdebug-ide


#78 Debugger::PROG_SCRIPT = ARGV.shift
#replace with following:

script = ARGV.shift
Debugger::PROG_SCRIPT = (script =~ /script([\\\/])rails/ ? Dir.pwd + $1 : '') + script

Otherwise, you will get missing file error in Netbeans or other types of IDEs, when you try to debug.

Finally, if you are using Macport version of Ruby 1.9.2, you need to added the CA certificate. Otherwise, Ruby will complain with following error

OpenSSL::SSL::SSLError SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed


#solution

sudo curl http://curl.haxx.se/ca/cacert.pem -o /opt/local/etc/openssl/cert.pem