2014-05-02 72 views
13

我試圖安裝一個gem,並且我得到了這個錯誤,這是我自己和gem作者以前從未見過的。我該如何解決?錯誤:無法構建gem本機擴展(ruby extconf.rb):Mac OSX

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

嘗試使用'rvm'或'rbenv'而不是通過我認爲是'brew'安裝Ruby。 –

+1

似乎有點類似? http://stackoverflow.com/questions/22352838/ruby-gem-install-json-fails-on-mavericks-and-xcode-5-1-unknown-argument-mul – Alex

回答

13

試試這個:

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

有關說明使用xcode-select --install我沒有工作,看到this answer

-1

這是蘋果LLVM錯誤。

現在,您可以:

export ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future" 

雖然你可以從警告這名不是一個永久性的解決方案看。

來源:https://langui.sh/2014/03/10/wunused-command-line-argument-hard-error-in-future-is-a-harsh-mistress/

+0

我跟着那個帖子,但仍然得到相同的'clang:error:unknown argument:'-multiply_definedsuppress'[-Wunused-command-line-argument-hard-error-in-future] clang:注意:這將是一個硬錯誤(不能降級爲警告)未來 make:*** [ffi_c.bundle]錯誤1 Gem文件仍將安裝在/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 - 命令行參數 - 硬錯誤 - 未來的想法? –

+1

接受的答案與9天后的答案相同。 ( – dx7

17

如果這是在OSX小牛隊的現象發生,請確保在命令行工具運行以下安裝。

舊版本的OSX & XCode在XCode IDE本身中安裝了命令行工具。在OSX Mavericks中,我不得不運行下面的命令來修復命令行工具,以便使用本機擴展來安裝rubygems。

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

)您是否閱讀了賞金說明?安裝命令不再有效http://imgur.com/yNM2RRC –

+0

我的歉意,我必須跳過最後一個鏈接,我正在看看其他圖片,如果我想到了什麼,我會更新 – Chris

+2

你可以直接從蘋果網站下載命令行工具登錄,它應該是一些條目下載https://developer.apple.com/downloads/index.action# – Cereal

0

在OSX-10.9.5。它開始並要求確認許可證,但之後報告說它找不到該軟件。

我結束了訪問:https://developer.apple.com/downloads/index.action#,下載相應的CommandLineTools DMG的OSX-10.9.5,從PKG手動安裝工具,然後使用:xcode-select --switch=/Library/Developer/CommandLineTools,設置路徑。

之後,一切正常。

相關問題