当我输入
→ sudo gem install rails
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/usr/local/opt/ruby/bin/ruby -r ./siteconf20161130-77662-u8g67w.rb extconf.rb
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/Cellar/ruby/2.3.1_2/bin/$(RUBY_BASE_NAME)
--help
--clean
--use-system-libraries
/usr/local/lib/ruby/site_ruby/2.3.0/rubygems/dependency.rb:308:in `to_specs': Could not find 'mini_portile2' (~> 2.1.0) among 6 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/Users/MAMIAN/.gem/ruby/2.3.0:/usr/local/lib/ruby/gems/2.3.0:/usr/local/Cellar/ruby/2.3.1_2/lib/ruby/gems/2.3.0', execute `gem env` for more information
from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/dependency.rb:320:in `to_spec'
from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_gem.rb:65:in `gem'
from extconf.rb:468:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /usr/local/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.8.1 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-15/2.2.0/nokogiri-1.6.8.1/gem_make.out
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin15]
rvm 1.27.0 (latest) by Wayne E. Seguin [email protected], Michal Papis [email protected] [https://rvm.io/]
Google 查了查,上面的方法都试了,还是不行,特地来问下
macOS 10.12
已经解决了,利用 rvm 安装了 ruby 解决