Steps to Build Ruby Development Environment with RVM on Mac OS X Lion
I’ll introduce the steps to set up a Ruby development environment using the Ruby version management tool RVM on Mac OS Lion with Xcode 4.1.
apple-gcc42 のインストール / Installing apple-gcc42
(Skip this section if you’re using Xcode 4.1 or earlier)
■ Method 1
First, if you’re using Xcode 4.2, the supported gcc has changed, so install apple-gcc42 that was previously included.
・[Mac] Homebrew で apple-gcc42 をインストールする方法 | CodeNote.net
If you haven’t installed Homebrew, please refer to this:
・[Mac] Homebrew をインストール | CodeNote.net
■ Method 2
Use OSX GCC Installer.
・kennethreitz/osx-gcc-installer
RVMのインストール / Installing RVM
Install the Ruby version management tool RVM.
$ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
Next, add configuration to ~/.bash_profile.
If it’s already created and has settings written, you don’t need to do anything special.
$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
After configuration, reload .bash_profile.
$ source ~/.bash_profile
Readlineなどの必要なライブラリーのインストール / Installing Required Libraries like Readline
Install libraries as needed.
Before installing with the rvm command, temporarily change environment variables.
export ARCHFLAGS="-arch x86_64"
export CC='gcc-4.2'
At minimum, install readline, and install others as needed.
rvm pkg install readline
rvm pkg install iconv
rvm pkg install zlib
rvm pkg install openssl
Rubyをバージョン指定してインストール / Installing Ruby with Version Specification
Install stable versions of Ruby 1.9.3, 1.9.2, and 1.8.7.
rvm install 1.9.3
rvm install 1.9.2
rvm install 1.8.7
Verify that each was installed successfully.
$ rvm list
rvm rubies
ruby-1.8.7-p357 [ i686 ]
ruby-1.9.2-p290 [ x86_64 ]
ruby-1.9.3-p0 [ x86_64 ]
# Default ruby not set. Try 'rvm alias create default '.
# => - current
# =* - current && default
# * - default
デフォルトの Ruby のバージョンを設定 / Setting Default Ruby Version
Finally, specify the Ruby version to use by default.
This time, I’ll set Ruby 1.9.3 as the default.
$ rvm use 1.9.3 --default
Using /Users/your_username/.rvm/gems/ruby-1.9.3-p0
Verify that it was set correctly.
$ ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.3.0]
$ rvm list
rvm rubies
ruby-1.8.7-p357 [ i686 ]
ruby-1.9.2-p290 [ x86_64 ]
=* ruby-1.9.3-p0 [ x86_64 ]
# => - current
# =* - current && default
# * - default
That’s all from the Gemba regarding setting up Ruby development environment with RVM.