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

时间:2011-12-02 17:37:42

标签: ruby-on-rails testing rspec cucumber

我正在尝试为导轨设置黄瓜。我把它包含在我的Gemfile中并运行bundle install。

  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.

1 个答案:

答案 0 :(得分:3)

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

问题似乎与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/bin/gcc rbenv install 1.9.3-p125
  • 成功安装了1.9.3-p125

复杂但我现在可以安装具有延伸扩展名的宝石。

希望这有帮助。

更新: btw。可以继续使用ruby-1.9.2-p290,您只需重新安装即可。

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