上次发了一个帖子『别在服务器上装 RVM』,总结了在服务器使用 RVM 的各种坑。虽然这些坑在不断的 Google 之后都可以解决,最终你会觉得在服务器安装 RVM 带来的麻烦比便利多。
最终选择了ruby-install
+ chruby
这套组合。为什么叫“Postmodern”Way?因为这两个 gem 的作者都是 postmodern.
相比 RVM,ruby-install
+ chruby
的特点就是简单、直接:
While I don't spend much time working on chruby/ruby-install due to their imposed simplicity, I do spend A LOT of time triaging issues.
Most of the chruby/ruby-install issues are either 1) misconfigurations 2) platform specific issues 3) upstream issues with MRI.
wget -O ruby-install-0.4.3.tar.gz https://github.com/postmodern/ruby-install/archive/v0.4.3.tar.gz
tar -xzvf ruby-install-0.4.3.tar.gz
cd ruby-install-0.4.3/
sudo make install
sudo ruby-install -p https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/2.1.2/railsexpress/01-zero-broken-tests.patch -p https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/2.1.2/railsexpress/02-improve-gc-stats.patch -p https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/2.1.2/railsexpress/03-display-more-detailed-stack-trace.patch -p https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/2.1.2/railsexpress/04-show-full-backtrace-on-stack-overflow.patch -p https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/2.1.2/railsexpress/05-fix-missing-c-return-event.patch -p https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/2.1.2/railsexpress/06-backport-006e66b6680f60adfb434ee7397f0dbc77de7873.patch -p https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/2.1.2/railsexpress/07-funny-falcon-stc-density.patch -p https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/2.1.2/railsexpress/08-funny-falcon-stc-pool-allocation.patch -p https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/2.1.2/railsexpress/09-aman-opt-aset-aref-str.patch -p https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/2.1.2/railsexpress/10-funny-falcon-method-cache.patch --rubies-dir /opt/rubies ruby 2.1.2
sudo mv /usr/local/bin/erb /usr/local/bin/erb19
sudo mv /usr/local/bin/gem /usr/local/bin/gem19
sudo mv /usr/local/bin/irb /usr/local/bin/irb19
sudo mv /usr/local/bin/rake /usr/local/bin/rake19
sudo mv /usr/local/bin/rdoc /usr/local/bin/rdoc19
sudo mv /usr/local/bin/ri /usr/local/bin/ri19
sudo mv /usr/local/bin/ruby /usr/local/bin/ruby19
sudo mv /usr/local/bin/testrb /usr/local/bin/testrb19
sudo mv /usr/local/bin/bundle /usr/local/bin/bundle19
sudo ln -sf /opt/rubies/ruby-2.1.2/bin/erb /usr/local/bin/erb
sudo ln -sf /opt/rubies/ruby-2.1.2/bin/gem /usr/local/bin/gem
sudo ln -sf /opt/rubies/ruby-2.1.2/bin/irb /usr/local/bin/irb
sudo ln -sf /opt/rubies/ruby-2.1.2/bin/rake /usr/local/bin/rake
sudo ln -sf /opt/rubies/ruby-2.1.2/bin/rdoc /usr/local/bin/rdoc
sudo ln -sf /opt/rubies/ruby-2.1.2/bin/ri /usr/local/bin/ri
sudo ln -sf /opt/rubies/ruby-2.1.2/bin/ruby /usr/local/bin/ruby
sudo ln -sf /opt/rubies/ruby-2.1.2/bin/testrb /usr/local/bin/testrb
sudo ln -sf /opt/rubies/ruby-2.1.2/bin/bundle /usr/local/bin/bundle
如果你没有在服务器上切换 Ruby 版本的需要,根本不用安装 chruby.
wget -O chruby-0.3.8.tar.gz https://github.com/postmodern/chruby/archive/v0.3.8.tar.gz
tar -xzvf chruby-0.3.8.tar.gz
cd chruby-0.3.8/
sudo make install
只需要在 ~/.bash_profile
里加一句:
source /usr/local/share/chruby/chruby.sh
chruby ruby-2.1.2