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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7645918/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 02:05:37  来源:igfitidea点击:

`require': no such file to load -- mkmf (LoadError)

ruby-on-railsubuntu

提问by Omar S.

I was trying to install rails on Ubuntu Natty Narwhal 11.04, using ruby1.9.1.

我试图使用 ruby​​1.9.1 在 Ubuntu Natty Narwhal 11.04 上安装 rails。

I installed ruby using apt-get install ruby1.9.1-fullwhich contains the dev package. I googled the error and all have suggested I install the 1.9.1-dev which I already have.

我使用apt-get install ruby1.9.1-full包含开发包的ruby 安装了 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

回答by Emil Ivanov

After some search for a solution it turns out the -devpackage is needed, not just ruby1.8. So if you have ruby1.9.1doing

经过一番搜索解决方案后,结果证明-dev需要该包,而不仅仅是ruby1.8. 所以如果你有ruby1.9.1

sudo apt-get install ruby1.9.1-dev

or to install generic ruby version, use (as per @lamplightdev comment):

或安装通用 ruby​​ 版本,使用(根据@lamplightdev 评论):

sudo apt-get install ruby-dev

should fix it.

应该修复它。

Try locate mkmfto see if the file is actually there.

尝试locate mkmf查看该文件是否确实存在。

回答by jmontross

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

这是对我有用的答案。在上面的评论中,但作为 ubuntu 12.04 ruby​​ 1.8.7 的答案理应得到应有的地位

sudo apt-get install ruby-dev
# if above doesnt work make sure you have build essential
sudo apt-get install build-essential

回答by James Dunmore

I also needed build-essential installed:

我还需要安装 build-essential:

sudo apt-get install build-essential

回答by kenju254

The problem is still is recursive on Ubuntu 13/04/13.10/14.04

问题仍然是在 Ubuntu 13/04/13.10/14.04 上递归

and

sudo apt-get install ruby1.9.1-dev

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.

对我很好。因此,如果您使用的是 Ubuntu 13.04/13.10/14.04,那么使用它真的会派上用场。

This works even if ruby version is 1.9.3. This is because there is no ruby1.9.3-dev available in the Repository...

即使 ruby​​ 版本是 1.9.3,这也有效。这是因为存储库中没有 ruby​​1.9.3-dev 可用...

回答by Matteo Alessani

Have you tried:

你有没有尝试过:

sudo apt-get install ruby1.8-dev

回答by Sergey Nikolaev

I got the similar error when install bundle

安装包时出现类似错误

sudo apt-get install ruby-dev

Works great for me and solve the problem Mint 16 ruby1.9.3

非常适合我并解决问题 Mint 16 ruby​​1.9.3

回答by JGutierrezC

I think is a little late but

我觉得有点晚了但是

sudo yum install -y gcc ruby-devel libxml2 libxml2-devel libxslt libxslt-devel

worked for me on fedora.

在 Fedora 上对我来说有效。

http://nokogiri.org/tutorials/installing_nokogiri.html

http://nokogiri.org/tutorials/installing_nokogiri.html

回答by kenorb

You've Ruby 1.8 so you need to upgrade to at least 1.9 to make it working.

您使用的是 Ruby 1.8,因此您至少需要升级到 1.9 才能使其正常工作。

If so, then check How to install a specific version of a ruby gem?

如果是这样,请检查如何安装特定版本的 ruby​​ gem?

If this won't help, then reinstalling ruby-devagain.

如果这没有帮助,请重新安装ruby-dev

回答by Mohit Verma

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 )

您可以使用 RVM(Ruby 版本管理器),它有助于管理您机器上的所有 ruby​​ 版本,这对您的开发非常有帮助(从不稳定版本迁移到稳定版本时)

or for Linux (ubuntu) go for sudo apt-get install ruby1.8-dev

或者对于 Linux (ubuntu) 去 sudo apt-get install ruby1.8-dev

then sudo gem install railsto verify it do rails -vit will show version on rails

然后sudo gem install rails验证它 rails -v会在导轨上显示版本

after that you can install bundles (required gems for development)

之后,您可以安装捆绑包(开发所需的宝石)