ERROR: 构建本地扩展宝石失败(ruby extconf.rb):Mac OSX

13

我正在尝试安装一个 gem,但是我遇到了这个错误,我和 gem 的作者都从未见过。我应该如何修复它?

Davids-MacBook-Pro:web david$ sudo /usr/bin/gem install compass --pre
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing compass:
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... yes
checking for ffi_call() in -lffi... yes
checking for ffi_prep_closure()... yes
checking for ffi_raw_call()... no
checking for rb_thread_blocking_region()... yes
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_call_without_gvl()... yes
checking for ffi_prep_cif_var()... no
creating extconf.h
creating Makefile

make "DESTDIR="
compiling AbstractMemory.c
compiling ArrayType.c
compiling Buffer.c
compiling Call.c
Call.c:303:5: warning: implicit declaration of function 'rb_thread_call_without_gvl' is invalid in C99 [-Wimplicit-function-declaration]
rbffi_thread_blocking_region(call_blocking_function, data, (void *) -1, NULL);
^
./Thread.h:78:39: note: expanded from macro 'rbffi_thread_blocking_region'
# define rbffi_thread_blocking_region rb_thread_call_without_gvl
                                  ^
1 warning generated.
compiling ClosurePool.c
compiling DataConverter.c
DataConverter.c:43:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 warning generated.
compiling DynamicLibrary.c
compiling ffi.c
compiling Function.c
Function.c:479:33: warning: incompatible pointer types passing 'VALUE (void *)' to parameter of type 'void *(*)(void *)' [-Wincompatible-pointer-types]
    rb_thread_call_with_gvl(callback_with_gvl, &cb);
                            ^~~~~~~~~~~~~~~~~
Function.c:102:46: note: passing argument to parameter 'func' here
extern void *rb_thread_call_with_gvl(void *(*func)(void *), void *data1);
                                         ^
Function.c:563:9: warning: implicit declaration of function 'rb_thread_call_without_gvl' is invalid in C99 [-Wimplicit-function-declaration]
    rb_thread_call_without_gvl(async_cb_wait, &w, async_cb_stop, &w);
    ^
Function.c:738:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
3 warnings generated.
compiling FunctionInfo.c
compiling LastError.c
compiling LongDouble.c
compiling MappedType.c
compiling MemoryPointer.c
compiling MethodHandle.c
compiling Platform.c
compiling Pointer.c
compiling Struct.c
compiling StructByReference.c
compiling StructByValue.c
compiling StructLayout.c
compiling Thread.c
compiling Type.c
compiling Types.c
compiling Variadic.c
linking shared-object ffi_c.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [ffi_c.bundle] Error 1


Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/ffi-1.9.3 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/ffi-1.9.3/ext/ffi_c/gem_make.out

1
尝试使用类似于rvmrbenv的工具,而不是通过我假设是brew安装Ruby。 - Justin Wood
1
似乎有类似的问题?https://dev59.com/ZmEh5IYBdhLWcg3wfjiq - Alex
4个回答

17

如果这在OSX Mavericks中发生,请确保通过运行以下命令安装了命令行工具。

早期版本的OSX和XCode在XCode IDE本身中提供了Command Line Tools的安装。在OSX Mavericks中,我不得不运行下面的命令来修复我的命令行工具,以便我可以使用本机扩展安装rubygems。

$ sudo xcode-select --install
$ xcode-select --print-path
/Library/Developer/CommandLineTools

你读了赏金描述吗?安装命令不再起作用 http://imgur.com/yNM2RRC - David Williams
抱歉,我可能跳过了最后一个链接。我正在查看其他图片,如果我想到什么,我会更新的。 - Chris
2
您可以直接从苹果官网下载命令行工具。登录后,它应该在下面的几个条目中。https://developer.apple.com/downloads/index.action# - Cereal
2
$ sudo xcode-select --install 可以在 Yosemite .1 上运行。 - crazyGuy
7
在我的Mavericks上运行安装命令后,'xcode-select --print-path'会返回'/Applications/Xcode.app/Contents/Developer'。 - Per Quested Aronsson

13

试试这个:

ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install <gemName>

如果需要解释,请参见此答案


0
在OSX-10.9.5上,使用xcode-select --install命令无法解决问题。它开始运行并要求确认许可证,但随后报告找不到软件。
最终我访问了https://developer.apple.com/downloads/index.action#,下载了适用于OSX-10.9.5的CommandLineTools dmg文件,从pkg手动安装工具,然后使用xcode-select --switch=/Library/Developer/CommandLineTools设置路径。
之后一切都正常工作了。

-1

我遵循了那篇文章,但仍然得到相同的错误提示:clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future] clang: note: this will be a hard error (cannot be downgraded to a warning) in the future make: *** [ffi_c.bundle] Error 1宝石文件将保留在/Library/Ruby/Gems/2.0.0/gems/ffi-1.9.3以供检查。结果记录在/Library/Ruby/Gems/2.0.0/gems/ffi-1.9.3/ext/ffi_c/gem_make.out中。Davids-MacBook-Pro:〜david $ echo $ARCHFLAGS -Wno-error = unused-command-line-argument-hard-error-in-future`有什么想法吗? - David Williams
1
9天后,被接受的答案与此答案相同。 :( - dx7

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接