安装rails出错:未能构建本机gem的扩展2019-03-19

在执行gem install rails -v 5.0.0时出错:

bogon:~ jinzesu$ gem install rails -v 5.0.0

Building native extensions. This could take a while…

ERROR: Error installing rails:

ERROR: Failed to build gem native extension.

current directory: /Users/jinzesu/.rvm/gems/ruby-2.3.1/gems/nokogiri-1.10.1/ext/nokogiri

1

/Users/jinzesu/.rvm/rubies/ruby-2.3.1/bin/ruby -I /Users/jinzesu/.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0 -r ./siteconf20190302-2602-fo4900.rb extconf.rb

checking if the C compiler accepts -I /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libxml2… 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/include−−with−opt−lib−−without−opt−lib={opt-dir}/lib

–with-make-prog

–without-make-prog

–srcdir=.

–curdir

–ruby=/Users/jinzesu/.rvm/rubies/ruby-2.3.1/bin/$(RUBY_BASE_NAME)

–help

–clean

–use-system-libraries

/Users/jinzesu/.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in require': cannot load such file -- openssl (LoadError) from /Users/jinzesu/.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:inrequire’

from /Users/jinzesu/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/net/https.rb:23:in ' from /Users/jinzesu/.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:inrequire’

from /Users/jinzesu/.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in require' from /Users/jinzesu/.rvm/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:3:in

from /Users/jinzesu/.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in require' from /Users/jinzesu/.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:inrequire’

from /Users/jinzesu/.rvm/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/mini_portile2-2.4.0/lib/mini_portile2.rb:2:in ' from /Users/jinzesu/.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:inrequire’

from /Users/jinzesu/.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in require' from extconf.rb:470:in’

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/Users/jinzesu/.rvm/gems/ruby-2.3.1/extensions/x86_64-darwin-18/2.3.0/nokogiri-1.10.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/jinzesu/.rvm/gems/ruby-2.3.1/gems/nokogiri-1.10.1 for inspection.

Results logged to /Users/jinzesu/.rvm/gems/ruby-2.3.1/extensions/x86_64-darwin-18/2.3.0/nokogiri-1.10.1/gem_make.out

解决方法如下:

gem install nokogiri -- --use-system-libraries 

你可能感兴趣的:(安装rails出错:未能构建本机gem的扩展2019-03-19)