注意:不能以root来跑

先安装rvm

curl -sSL https://rvm.io/mpapis.asc | gpg --import -; curl -L get.rvm.io | bash -s stable

 

source ~/.rvm/scripts/rvm

 

修改rvm的安装源为淘宝,提高安装速度(现在都用https)

mac

sed -i .bak -E 's!https?://cache.ruby-lang.org/pub/ruby!https://ruby.taobao.org/mirrors/ruby!' $rvm_path/config/db

 

linux

sed -i -E 's!https?://cache.ruby-lang.org/pub/ruby!https://ruby.taobao.org/mirrors/ruby!' $rvm_path/config/db

 

 

安装必须的东西

rvm requirements


看看装哪个ruby

rvm list known


2.1.3貌似最新

rvm install ruby-



设置默认

rvm use ruby-2.3.0 --default

 


如果看到

RVM is not a function, selecting rubies with 'rvm use ...' will not work.

You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for an example.

则在.bashrc添加

source ~/.rvm/scripts/rvm

重启bash

 

修改gem的源到淘宝

 

gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/


下面直接安装rails

gem install rails --no-doc -V

 

修改默认源,命令行中运行:

bundle config mirror.https://rubygems.org https://ruby.taobao.org

 

用法:

rails new helloWorld --skip-bundle
cd helloWorld
bundle install