‘require’:没有要加载的文件 - mkmf (LoadError)

发布于 2024-12-08 14:00:34 字数 643 浏览 1 评论 0原文

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

我使用 apt-get install ruby​​1.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

冰雪梦之恋 2024-12-15 14:00:34

经过一番搜索解决方案后,发现需要 -dev 包,而不仅仅是 ruby1.8。因此,如果您有 ruby1.9.1 正在执行

sudo apt-get install ruby1.9.1-dev

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

sudo apt-get install ruby-dev

应该修复它。

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

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

sudo apt-get install ruby1.9.1-dev

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

sudo apt-get install ruby-dev

should fix it.

Try locate mkmf to see if the file is actually there.

灵芸 2024-12-15 14:00:34

这是对我有用的答案。在上面的评论中,但值得作为 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

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

sudo apt-get install ruby-dev
# if above doesnt work make sure you have build essential
sudo apt-get install build-essential
囚我心虐我身 2024-12-15 14:00:34

我还需要安装 build-essential:

sudo apt-get install build-essential

I also needed build-essential installed:

sudo apt-get install build-essential
葬シ愛 2024-12-15 14:00:34

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

,并且

sudo apt-get install ruby1.9.1-dev

对我来说没问题。所以如果你使用的是 Ubuntu 13.04/13.10/14.04 那么使用它真的会派上用场。

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

The problem is still is recursive on 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.

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

别低头,皇冠会掉 2024-12-15 14:00:34

你有没有尝试过:

sudo apt-get install ruby1.8-dev

Have you tried:

sudo apt-get install ruby1.8-dev
随心而道 2024-12-15 14:00:34

安装捆绑包时我遇到了类似的错误,

sudo apt-get install ruby-dev

这对我来说非常有用并解决了问题
薄荷16红宝石1.9.3

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

☆獨立☆ 2024-12-15 14:00:34

我认为有点晚了,但

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

在 Fedora 上对我有用。

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

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.

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

2024-12-15 14:00:34

您已经使用 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.

看春风乍起 2024-12-15 14:00:34

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

或 Linux(ubuntu) 非常有帮助
sudo apt-get install ruby​​1.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 do rails -v it will show version on rails

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

浅听莫相离 2024-12-15 14:00:34

红宝石版本:2.7.1
gem版本:3.1.3

需要检查无法安装的扩展,并查找原因。

阅读“要了解此扩展无法编译的原因,请检查可在此处找到的 mkmf.log”下安装错误时显示的 mkmf.log 文件,也许缺少一个库(有时是 iconv ),您必须安装它。

您也可以使用包管理器(apt、yum、pacman...)搜索扩展。

(个人案例)Arch Linux->nokogiri

gem install rails

向我展示了:

要了解此扩展无法编译的原因,请检查 mkmf.log
可以在这里找到:
/home/user/.gem/ruby/2.7.0/extensions/x86_64-linux/2.7.0/nokogiri-1.10.9/mkmf.log

转到:https://aur.archlinux.org/packages/ruby-nokogiri/

  1. 确保已安装所有依赖项
  2. 确保已安装 make
  3. git clone code> 软件包
  4. cd 到软件包
  5. 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

gem install rails

Showed me:

To see why this extension failed to compile, please check the mkmf.log
which can be found here:
/home/user/.gem/ruby/2.7.0/extensions/x86_64-linux/2.7.0/nokogiri-1.10.9/mkmf.log

Go to: https://aur.archlinux.org/packages/ruby-nokogiri/

  1. Make sure you have all dependencies installed
  2. Make sure you have make installed
  3. git clone the package
  4. cd to package
  5. makepkg the package

Hope to help!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文