RSS
 

Ruby1.9.2をRVMで試す(ubuntu10.04)

22 8月




__________________________
■Ruby1.9.2

.rb をパースし、AST、バイトコードと中間言語にコンパイルして
仮想マシンで実行する方式と変わったので高速化されたようです。

http://www.ruby-lang.org/ja/news/2010/08/18/ruby-1-9-2-is-released/

__________________________
■RVM

Ruby Version Managerを指し、
1台のマシンに複数のRubyをインストールして切る変えることができる便利なツール。

http://rvm.beginrescueend.com/

__________________________
■Ruby1.9.2をRVMで試す(ubuntu10.04)

——————————–

% gem install rvm
→ rvm をインストール

% rvm-install
→ 示された手順※に従って行う

% rvm update –head
→gitから最新のものを取得する

% rvm install 1.9.2
→/home/???/.rvm/rubies/ruby-1.9.2-p0 にinstallされる
やっていることは、
Cで書かれたソースをコンパイルしてバイナリにして実行ディレクトリにコピー
configure→make→make install

% rvm use 1.9.2
→これで切り替え完了、
irbでRUBY_VERSIONと入力すると=> “1.9.2″!
また、env | grep PATH で確認してみると
/home/???/.rvm/gems/ruby-1.9.2-p0/bin!

おぉぉ!
ruby-1.9.2-p0 > p = Hash.new
=> {}
ruby-1.9.2-p0 > p = {a:1,b:2}
=> {:a=>1, :b=>2}

なお元に戻したければ、ターミナルを再度立ち上げる。

——————————–

※ 示された手順

1) Place the folowing line at the end of your shell’s loading files(.bashrc or .bash_profile for bash and .zshrc for zsh), after all path/variable settings:
[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm
Please note that this must only occur once – so, you only need to add it the first time you install rvm.
2) Ensure that there is no ‘return’ from inside the .bashrc file. (otherwise rvm will be prevented from working properly).
This means that if you see ‘[ -z "$PS1" ] && return’ then you must change this line to:
if [[ -n "$PS1" ]] ; then
… original content that was below the && return line …
fi # <= be sure to close the if.
#EOF .bashrc
Be absolutely *sure* to REMOVE the ‘&& return’.
If you wish to DRY up your config you can ‘source ~/.bashrc’ at the bottom of your .bash_profile.
placing all non-interactive items in the .bashrc, including the ‘source’ line above
3) Then CLOSE THIS SHELL and open a new one in order to use rvm.

WARNING: you have a ‘return’ statement in your .bashrc, likely this will cause untold havoc.
This means that if you see ‘[ -z "$PS1" ] && return’ then you must change this line to:
if [[ -n "$PS1" ]] ; then
… original content that was below the && return line …
fi # <= be sure to close the if.
#EOF .bashrc
Even if you use zsh you should still adjust the .bashrc as above.
If you have any questions about this please visit #rvm on irc.freenode.net.

__________________________
■今回のハマり

1点目
.gemrcにて –user-install としホームディレクトリは以下にgemを
インストールするように設定していたが、これを無効にしないとだめだった。

2点目
ターミナルを1回立ち上げなおしでは一部反映されず、2回立ち上げなおしをしたら反映された、、

 
 

Leave a Reply

 
*