安装Rails踩过的坑

安装ruby on rails时遇到的坑,慢慢踩,慢慢收集

 

错误:

ERROR: Failed to build gem native extension. /usr/bin/ruby extconf.rb mkmf.rb can't find 
header files for ruby at /usr/share/include/ruby.h

解决办法:

1.Linux Centos 系统下执行 :yum install ruby-devel
2.Linux Ubuntu 系统下执行:apt-get install ruby-dev

错误:

gem install nokogiri 失败: Error installing nokogiri

ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-apple-darwin13.1.0/ports/libxml2/2.8.0... OK
Running 'configure' for libxml2 2.8.0... OK
Running 'compile' for libxml2 2.8.0... OK
Running 'install' for libxml2 2.8.0... OK
Activating libxml2 2.8.0 (from /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.1/ports/x86_64-apple-darwin13.1.0/libxml2/2.8.0)...
Extracting libxslt-1.1.26.tar.gz into tmp/x86_64-apple-darwin13.1.0/ports/libxslt/1.1.26... OK
Running 'configure' for libxslt 1.1.26... OK
Running 'compile' for libxslt 1.1.26... OK
Running 'install' for libxslt 1.1.26... OK
Activating libxslt 1.1.26 (from /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.1/ports/x86_64-apple-darwin13.1.0/libxslt/1.1.26)...
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... yes
checking for xmlParseDoc() in -lxml2... no
-----
libxml2 is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file f

解决办法:

sudo apt-get install libxslt-dev libxml2-dev
sudo apt-get install zlib1g-dev  #安装第三方包的依赖库

 

安装第三方包如果感觉速度太慢就换源

$ gem source -r https://rubygems.org/ 
$ gem source -a https://gems.ruby-china.com/

要想验证是否替换成功了,可以执行:

$ gem sources -l 

 

最终安装清单

sudo apt-get install ruby
sudo apt-get install ruby-dev
sudo apt install ruby-bundler
sudo apt-get install libxslt-dev libxml2-dev
sudo apt-get install zlib1g-dev  #安装第三方包的依赖库
sudo apt-get install libsqlite3-dev
sudo gem install nokogiri
sudo gem install rails
sudo gem install bundler

 

posted @ 2019-05-30 15:27  枫奇丶宛南  阅读(60)  评论(0编辑  收藏  举报