为了账号安全,请及时绑定邮箱和手机立即绑定

无法安装gem-无法构建gem本机扩展-无法加载此类文件-mkmf(LoadError)

/ 猿问

无法安装gem-无法构建gem本机扩展-无法加载此类文件-mkmf(LoadError)

慕盖茨9453107 2019-10-17 15:24:25

Ruby 1.9.3


Gemfile的一部分


#...............

gem "pony"

gem "bcrypt-ruby", :require => "bcrypt"

gem "nokogiri" 

#..................

当我尝试安装gems时,出现错误


alex@ubuntu:~/$ bundle

Fetching gem metadata from http://rubygems.org/.........

Fetching gem metadata from http://rubygems.org/..

Enter your password to install the bundled RubyGems to your system: 

#####............................................................

Installing bcrypt-ruby (3.0.1) with native extensions 

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.


        /usr/bin/ruby1.9.1 extconf.rb 

/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)

        from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'

        from extconf.rb:36:in `<main>'



Gem files will remain installed in /home/alex/.bundler/tmp/5526/gems/bcrypt-ruby-3.0.1 for inspection.

Results logged to /home/alex/.bundler/tmp/5526/gems/bcrypt-ruby-3.0.1/ext/mri/gem_make.out

An error occurred while installing bcrypt-ruby (3.0.1), and Bundler cannot continue.

Make sure that `gem install bcrypt-ruby -v '3.0.1'` succeeds before bundling.

那我在做


sudo gem install bcrypt-ruby -v '3.0.1'

Building native extensions.  This could take a while...

ERROR:  Error installing bcrypt-ruby:

        ERROR: Failed to build gem native extension.


        /usr/bin/ruby1.9.1 extconf.rb

/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)

        from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'

        from extconf.rb:36:in `<main>'



Gem files will remain installed in /var/lib/gems/1.9.1/gems/bcrypt-ruby-3.0.1 for inspection.

Results logged to /var/lib/gems/1.9.1/gems/bcrypt-ruby-3.0.1/ext/mri/gem_make.out

并得到一个错误。


我错过了什么?


查看完整描述

3 回答

?
POPMUISE

还有类似的问题:


`require':没有要加载的文件-mkmf(LoadError)

无法构建gem本机扩展(mkmf(LoadError))-Ubuntu 12.04

通常,解决方案是:


须藤apt-get install ruby-dev


或者,如果这不起作用,则取决于您的ruby版本,运行类似以下内容的代码:


须藤apt-get install ruby1.9.1-dev


应该解决您的问题。


还是行不通?安装ruby-dev后,尝试以下操作:


sudo apt-get安装make


查看完整回答
反对 回复 2019-10-17
?
翻阅古今

我在尝试安装jquery-rails时遇到了同样的问题。解决方法是


sudo apt-get install zlibc zlib1g zlib1g-dev


查看完整回答
反对 回复 2019-10-17
?
慕哥6287543

对于WSL(Linux的Windows子系统),您需要安装build-essential软件包:


sudo apt install build-essential


查看完整回答
反对 回复 2019-10-17

添加回答

回复

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信