所以我正在尝试安装audite gem,但是遇到了rbenv问题:
$ bundle install
Fetching gem metadata from https://rubygems.org/...
Installing audite (0.3.0)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/opt/boxen/rbenv/versions/1.9.3-p448/bin/ruby extconf.rb
checking for mpg123.h... no
*** 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.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/opt/boxen/rbenv/versions/1.9.3-p448/bin/ruby
please install mpg123 headers
Gem files will remain installed in /opt/boxen/rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/audite-0.3.0 for inspection.
Results logged to /opt/boxen/rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/audite-0.3.0/ext/mpg123/gem_make. out
An error occurred while installing audite (0.3.0), and Bundler cannot continue.
Make sure that `gem install audite -v '0.3.0'` succeeds before bundling.
我知道这些宝石需要c扩展,我用自制软件安装它们。如果我进入酒窖自制,我可以看到它正在寻找的文件(mpg123.h
)
/opt/boxen/homebrew/Cellar/mpg123/1.15.4/include/mpg123.h
那么,有没有办法将它添加到rbenv环境中而不需要将其直接复制或链接到/opt/boxen/rbenv/versions/1.9.3-p448/
答案 0 :(得分:2)
xcode-select --install
为我解决了。
答案 1 :(得分:1)
我遇到了尝试安装audite的相同问题。事实证明,mkmf写了一个文件调用mkmf.log来更具体地告诉你它是如何找出标题是否是availbale的:
>>> cat mkmf.log
have_header: checking for mpg123.h... -------------------- no
"xcrun cc -E -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -g -Os -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common conftest.c -o conftest.i"
xcode-select: Error: No Xcode is selected. Use xcode-select -switch <path-to-xcode>, or see the xcode-select manpage (man xcode-select) for further information.
checked program was:
/* begin */
1: #include <mpg123.h>
/* end */
--------------------
原来我还没有安装xcode;安装并运行后
xcode-select --print-path
我看到路径现已设定。然后我仍然必须运行 xcrun 一次才同意Apple的许可协议,但随后安装的安装就好了!
答案 2 :(得分:0)
将自制的include
目录添加到您的路径中,rubygems会找到它。这对rbenv来说并不是一个问题。
在默认安装中,自制程序将包的所有include
文件夹符号链接到/usr/local/include
,在您的情况下,这些文件夹应位于/opt/boxen/homebrew/include
中。只是环顾四周,应该有一个包含所有包含的文件夹。
答案 3 :(得分:0)
所以最后,下面的一件事情为我修好了,我不知道是什么因为自从我遇到这个问题以来我重建并改变了我的机器几次: