安装黄瓜时出错(涉及小黄瓜)

发布于 2024-12-19 06:37:18 字数 570 浏览 0 评论 0原文

我正在尝试为 Rails 设置黄瓜。我将其包含在 Gemfile 中并运行捆绑安装。

  gem 'cucumber-rails'
  gem 'database_cleaner'

我收到这个错误。我应该怎么办?

ERROR:  Error installing gherkin:
    ERROR: Failed to build gem native extension.

        /Users/[my_user_name]/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for main() in -lc... *** 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.

I'm trying to set up cucumber for rails. I included this in my Gemfile and ran bundle install.

  gem 'cucumber-rails'
  gem 'database_cleaner'

I got this error. What should I do?

ERROR:  Error installing gherkin:
    ERROR: Failed to build gem native extension.

        /Users/[my_user_name]/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for main() in -lc... *** 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

倚栏听风 2024-12-26 06:37:18

这个问题有点老了,但由于我的机器上刚刚遇到了类似的问题,我将在这里记录我的解决方案。

该问题似乎与 OS X Lion、GCC、clang 等有关(请参阅 https://github .com/carlhuda/bundler/issues/1590https://github.com/carlhuda/bundler/issues/1600)。由于 ruby​​ 的编译方式似乎是问题,我决定重新安装(并升级)ruby。

以下是为我解决这个问题的方法:

  • 我使用 Xcode 包的命令行工具。
  • 此外,当前版本的 rbenv 和 ruby​​-build(均通过自制程序安装)
  • rbenv install 1.9.3-p125 失败(请参阅https://github.com/sstephenson/ruby-build/issues/129https://github.com/sstephenson/ruby-build/issues/130
  • 删除1.9.3-p125 的 require_gcc 行(如果使用自制软件安装,您可以在下面找到该文件/usr/local/Cellar/ruby-build/20120216/share/ruby-build/1.9.3-p125)
  • 最终使用env CC=/usr/成功安装1.9.3-p125 bin/gcc rbenv install 1.9.3-p125

很复杂,但我现在可以安装带有本机扩展的 gems。

希望这有帮助。

更新:顺便说一句。可以继续使用 ruby​​-1.9.2-p290,您所要做的就是重新安装它。

  • 首先“卸载”旧的 ruby​​-1.9.2-p290: rm -rf .rbenv/versions/1.9.2-p290
  • 接下来删除 1.9.2 的 require_gcc 行-p290
  • 最后使用 env CC=/usr/bin/gcc rbenv install 1.9.2-p290 安装

This question is a bit old, but as I just had a similar problem on my machine I will document my solution here.

The problem seems to be related to OS X Lion, GCC, clang etc. (see https://github.com/carlhuda/bundler/issues/1590 and https://github.com/carlhuda/bundler/issues/1600). As how ruby was compiled seems to be the problem I decided to re-install (and also upgrade) ruby.

Here is what solved this issue for me:

  • I use the Command Line Tools for Xcode package.
  • Furthermore the current version of rbenv and ruby-build (both installed via homebrew)
  • rbenv install 1.9.3-p125 failed (see https://github.com/sstephenson/ruby-build/issues/129 and https://github.com/sstephenson/ruby-build/issues/130)
  • remove the require_gcc line for 1.9.3-p125 (if installed with homebrew you find the file under /usr/local/Cellar/ruby-build/20120216/share/ruby-build/1.9.3-p125)
  • finally successfully install 1.9.3-p125 with env CC=/usr/bin/gcc rbenv install 1.9.3-p125

Complicated but I can now install gems with natiive extensions.

Hope this helps.

Update: btw. It is possible to keep using ruby-1.9.2-p290, all you have to do is re-install it.

  • First "uninstall" the old ruby-1.9.2-p290: rm -rf .rbenv/versions/1.9.2-p290
  • Next remove the require_gcc line for 1.9.2-p290
  • Finally install with env CC=/usr/bin/gcc rbenv install 1.9.2-p290
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文