系统需求
For Mac
- 先安装 Xcode 开发工具,它将帮你安装好 Unix 环境需要的开发包
- 然后安装 Homebrew$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
OS X 安装 Rails 必要的一些三方库
'$ brew install libxml2 libxslt libiconv'
RVM
rvm list known
rvm install 2.3.0
TODO
- 升级rvm(必须升级,不然有些最新版本ruby看不到)
- rvm get stable
- 安装ruby2.3.0
- rvm list known
- rvm install 2.3.0
- rvm use 2.3.0
- rvm use 2.3.0 --default
- rvm gemset create rails5.0
- rvm use 2.3.0@rails5.0
- rvm gemset list
- install rails
- gem -v # 2.5.1
- gem install rails
- gem sources 命令
+ gem sources -l
+ gem sources --add https://gems.ruby-china.org/
+ gem sources --add https://ruby.taobao.org/
+ gem sources --add http://ruby.sdutlinux.org/ 但是不好用
+ gem sources --remove https://ruby.taobao.org/
- 坑 nokogiri install faild
- $ gem uninstall nokogiri
- $ brew install libxml2 libxslt
- $ xcode-select --install 安装xcode 命令行工具, #我的系统已经安装了
- gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libxml2 --use-system-libraries #success,下面的都没用。
- $ NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri -- --use-system-libraries --with xml2-config="$(brew --prefix libxml2)/bin/xml2-config" --with-xslt-config="$(brew --prefix libxslt)/bin/xslt-config"
- gem install nokogiri -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.14/
- sudo env ARCHFLAGS="-arch x86_64" gem install nokogiri -- --use-system-libraries -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.2/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.2/lib --with-xslt-lib=/usr/local/Cellar/libxslt/1.1.28/lib --with-xslt-include=/usr/local/Cellar/libxslt/1.1.28/include
- 参考 install nokogiri Mac OS X
- gem search -r nokogiri 查找服务器上是否有nokogiri