linux下rvm安装ruby以及rubygems的过程分享

以前从来没有使用过ruby,这两天刚好要使用GitHub上的离线wiki系统gollum,所以要在偶的ubuntu下安装ruby和ruby-gems。其中遇到一些问题:


如果使用apt-get install ruby 和apt-get install rubygems1.8

当使用gem install 命令时报以下错误:


ERROR: While executing gem ... (TypeError) instance of Date needs to have method `marshal_load

 

可能是Ubuntu环境的原因,那么就改用rvm安装,参考了http://beginrescueend.com/rvm/install/ 

若以非root模式安装:


bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )


 添加rvm scripts路径变量到bash:


     echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile

   

 让新的bash生效:


     source ~/.bash_profile

 

安装ruby1.9.2:

    rvm install 1.9.2

  

让系统默认使用1.92:

    rvm use 1.9.2 --default



检查安装是否OK:

    ruby  -v

--------------------------------------------

接下来安装rubygems

先到官网下载安装包http://rubygems.org/pages/download


然后安装

ruby setup.rb


默认采用淘宝的Gem镜像站点


gem source http://ruby.taobao.org/


接下来就可以使用gem install xxx命令了,just enjoy it!


PS:如过使用gem install报错,可能是Ubuntu本身少一些依赖,比如我安装gollum时缺少依赖libxml2,libxslt,

缺少啥就 install 啥:


apt-get install libxml2

apt-get install libxslt

猜你喜欢

转载自hhlai1990.iteye.com/blog/1337523