错误:无法构建gem原生扩展。当试图安装rails

时间:2015-10-30 14:11:48

标签: ruby-on-rails ruby gem makefile

SYS:Ubuntu 14.04 Ruby版本:     ruby 2.2.3p173(2015-08-18修订版51636)[x86_64-linux] 宝石版:2.4.8

我不能说我在rails上有丰富的经验,但当我尝试在新计算机上部署rails时,我甚至无法安装rails。 这是gem_make.out文件
/usr/local/bin/ruby -r ./siteconf20151030-11581-1f0cbp1.rb extconf.rb checking if the C compiler accepts ... yes 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 --without-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/bin/$(RUBY_BASE_NAME) --help --clean --use-system-libraries /usr/local/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require': cannot load such file -- openssl (LoadError) from /usr/local/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:inrequire' from /usr/local/lib/ruby/2.2.0/net/https.rb:22:in <top (required)>' from /usr/local/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:inrequire' from /usr/local/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from /usr/local/lib/ruby/gems/2.2.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:3:in' from /usr/local/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in require' from /usr/local/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:inrescue in require' from /usr/local/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in require' from extconf.rb:395:in'

require': cannot load such file -- openssl (LoadError) from /usr/local/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in 由于我无法在make时使用Openssl,因此将https源替换为http。 有什么建议吗?

3 个答案:

答案 0 :(得分:1)

尝试以下操作以确保您拥有必要的库:

sudo apt-get install ruby-dev zlib1g-dev libgmp-dev libxml2-dev libssl-dev openssl

答案 1 :(得分:1)

是的,我找到了解决方法,这是基于@matanco的解决方案,mais他的解决方案尚未完成
sudo apt-get install ruby-dev zlib1g-dev libgmp-dev libxml2-dev libssl-dev openssl
执行此命令后,您应该再次编译ruby安装 sudo sh ./configure
sudo make
sudo make install

答案 2 :(得分:-1)

Ruby代码需要构建ssl本机库和标头。

这可以解决您的问题

sudo apt-get install libssl-dev