‘require’:没有要加载的文件 - mkmf (LoadError)
我试图使用 ruby1.9.1 在 Ubuntu Natty Narwhal 11.04 上安装 Rails。
我使用 apt-get install ruby1.9.1-full 安装了 ruby,其中包含开发包。我用谷歌搜索了这个错误,所有人都建议我安装我已经拥有的 1.9.1-dev。
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
extconf.rb:36:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:36
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/bcrypt-ruby-3.0.1 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/bcrypt-ruby-3.0.1/ext/mri/gem_make.out
I was trying to install rails on Ubuntu Natty Narwhal 11.04, using ruby1.9.1.
I installed ruby using apt-get install ruby1.9.1-full
which contains the dev package. I googled the error and all have suggested I install the 1.9.1-dev which I already have.
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
extconf.rb:36:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:36
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/bcrypt-ruby-3.0.1 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/bcrypt-ruby-3.0.1/ext/mri/gem_make.out
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
经过一番搜索解决方案后,发现需要
-dev
包,而不仅仅是ruby1.8
。因此,如果您有ruby1.9.1
正在执行或安装通用 ruby 版本,请使用(根据 @lamplightdev 评论):
应该修复它。
尝试
locate mkmf
看看该文件是否确实存在。After some search for a solution it turns out the
-dev
package is needed, not justruby1.8
. So if you haveruby1.9.1
doingor to install generic ruby version, use (as per @lamplightdev comment):
should fix it.
Try
locate mkmf
to see if the file is actually there.这是对我有用的答案。在上面的评论中,但值得作为 ubuntu 12.04 ruby 1.8.7 的答案
This is the answer that worked for me. Was in the comments above, but deserves its rightful place as answer for ubuntu 12.04 ruby 1.8.7
我还需要安装 build-essential:
I also needed build-essential installed:
问题在 Ubuntu 13/04/13.10/14.04 上仍然是递归的
,并且
对我来说没问题。所以如果你使用的是 Ubuntu 13.04/13.10/14.04 那么使用它真的会派上用场。
即使 ruby 版本是 1.9.3,这也有效。这是因为存储库中没有可用的 ruby1.9.3-dev...
The problem is still is recursive on Ubuntu 13/04/13.10/14.04
and
worked out for me okay. So If you are using Ubuntu 13.04/13.10/14.04 then using this will really come in handy.
This works even if ruby version is 1.9.3. This is because there is no ruby1.9.3-dev available in the Repository...
你有没有尝试过:
Have you tried:
安装捆绑包时我遇到了类似的错误,
这对我来说非常有用并解决了问题
薄荷16红宝石1.9.3
I got the similar error when install bundle
Works great for me and solve the problem
Mint 16 ruby1.9.3
我认为有点晚了,但
在 Fedora 上对我有用。
http://nokogiri.org/tutorials/installing_nokogiri.html
I think is a little late but
worked for me on fedora.
http://nokogiri.org/tutorials/installing_nokogiri.html
您已经使用 Ruby 1.8,因此您需要至少升级到 1.9 才能使其正常工作。
如果是这样,请检查如何安装特定版本的 ruby gem?
如果这没有帮助,请再次重新安装
ruby-dev
。You've Ruby 1.8 so you need to upgrade to at least 1.9 to make it working.
If so, then check How to install a specific version of a ruby gem?
If this won't help, then reinstalling
ruby-dev
again.您可以使用 RVM(Ruby 版本管理器),它有助于管理您计算机上的所有 Ruby 版本,这对您的开发(从不稳定版本迁移到稳定版本时)
或 Linux(ubuntu) 非常有帮助
sudo apt-get install ruby1.8-dev
然后
sudo gem install Rails
来验证它是否执行rails -v
它将在 Rails 上显示版本您可以安装捆绑包(开发所需的 gems)
You can use RVM(Ruby version manager) which helps in managing all versions of ruby on your machine , which is very helpful for you development (when migrating to unstable release to stable release )
or for Linux (ubuntu) go for
sudo apt-get install ruby1.8-dev
then
sudo gem install rails
to verify it dorails -v
it will show version on railsafter that you can install bundles (required gems for development)
红宝石版本:2.7.1
gem版本:3.1.3
需要检查无法安装的扩展,并查找原因。
阅读“要了解此扩展无法编译的原因,请检查可在此处找到的 mkmf.log”下安装错误时显示的 mkmf.log 文件,也许缺少一个库(有时是 iconv ),您必须安装它。
您也可以使用包管理器(apt、yum、pacman...)搜索扩展。
(个人案例)Arch Linux->nokogiri
向我展示了:
转到:https://aur.archlinux.org/packages/ruby-nokogiri/
make
git clone
code> 软件包cd
到软件包makepkg
软件包希望有帮助!
Ruby version: 2.7.1
gem version: 3.1.3
You need to check the extension that could not be installed, and find the reasons.
Read the mkmf.log file showed at the installation error under "To see why this extension failed to compile, please check the mkmf.log which can be found here" , perhaps there is a missing lib ( sometimes iconv ), and you must install it.
You can search the extension with your package manager(apt, yum, pacman...) too.
(Personal case) Arch Linux->nokogiri
Showed me:
Go to: https://aur.archlinux.org/packages/ruby-nokogiri/
make
installedgit clone
the packagecd
to packagemakepkg
the packageHope to help!