2013-01-17 40 views
1

安裝我的捆綁包時遇到問題。捆綁安裝無法在RVM上運行

這是我最後的步驟:

  • git clone http:...
  • git checkout -b daniel
  • bundle install

我得到的錯誤是:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native 
extension. 

     /Users/daniel/.rvm/rubies/ruby-1.9.3-p286/bin/ruby extconf.rb checking for main() in -lpthread... yes checking for main() in 
-lobjc... yes 
*** 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=/Users/daniel/.rvm/rubies/ruby-1.9.3-p286/bin/ruby 
    --with-pthreadlib --without-pthreadlib --with-objclib 
    --without-objclib --enable-debug --disable-debug 
/Users/daniel/.rvm/gems/ruby-1.9.3-p286/gems/therubyracer-0.11.0/ext/v8/build.rb:50:in 
`build_with_rubygem_libv8': undefined local variable or method 
`libv8_include_flags' for main:Object (NameError) from 
extconf.rb:20:in `<main>' 


Gem files will remain installed in 
/Users/daniel/.rvm/gems/ruby-1.9.3-p286/gems/therubyracer-0.11.0 for 
inspection. Results logged to 
/Users/daniel/.rvm/gems/ruby-1.9.3-p286/gems/therubyracer-0.11.0/ext/v8/gem_make.out 
An error occurred while installing therubyracer (0.11.0), and Bundler 
cannot continue. Make sure that `gem install therubyracer -v '0.11.0'` 
succeeds before bundling. 

當我試圖運行gem install therubyracer -v '0.11.0'我得到了:

Building native extensions. This could take a while... ERROR: Error 
installing therubyracer: ERROR: Failed to build gem native extension. 

     /Users/daniel/.rvm/rubies/ruby-1.9.3-p286/bin/ruby extconf.rb checking for main() in -lpthread... yes checking for main() in 
-lobjc... yes 
*** 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=/Users/daniel/.rvm/rubies/ruby-1.9.3-p286/bin/ruby 
    --with-pthreadlib --without-pthreadlib --with-objclib 
    --without-objclib --enable-debug --disable-debug 
/Users/daniel/.rvm/gems/ruby-1.9.3-p286/gems/therubyracer-0.11.0/ext/v8/build.rb:50:in 
`build_with_rubygem_libv8': undefined local variable or method 
`libv8_include_flags' for main:Object (NameError) from 
extconf.rb:20:in `<main>' 


Gem files will remain installed in 
/Users/daniel/.rvm/gems/ruby-1.9.3-p286/gems/therubyracer-0.11.0 for 
inspection. Results logged to 
/Users/daniel/.rvm/gems/ruby-1.9.3-p286/gems/therubyracer-0.11.0/ext/v8/gem_make.out 

我正在使用Mac OS 10.7.5。 Xcode及其命令行工具和Rails是最新的。 也安裝了SQLite 3。

任何人都可以幫助我嗎?


編輯:

我還試圖刪除存儲庫,並再次克隆它,用同樣的錯誤。


編輯:

是Rails和SQLITE3的安裝路徑是否正確?

daniel:~ 
daniel$ sudo gem update --system Latest version currently 
installed. Aborting. 
daniel:~ 
daniel$ sudo gem install rails 
Fetching: 
rails-3.2.11.gem (100%) Successfully installed 
rails-3.2.11 1 gem installed 
Installing ri documentation for rails-3.2.11... 
Installing RDoc documentation for rails-3.2.11... 
daniel:~ 
daniel$ sudo gem install sqlite3 
Fetching: sqlite3-1.3.7.gem (100%) 
Building native extensions. This could take a while... 
Successfully installed sqlite3-1.3.7 1 gem installed 
Installing ri documentation for sqlite3-1.3.7... 
Installing RDoc documentation for sqlite3-1.3.7... 
daniel:~ 
daniel$ which ruby irb gem rake 
/Users/daniel/.rvm/rubies/ruby-1.9.3-p286/bin/ruby 
/Users/daniel/.rvm/rubies/ruby-1.9.3-p286/bin/irb 
/Users/daniel/.rvm/rubies/ruby-1.9.3-p286/bin/gem 
/Users/daniel/.rvm/gems/ruby-1.9.3-p286/bin/rake 
+0

您接受了XCode許可協議嗎? –

+0

我可以啓動XCode並創建新項目等,所以我已經接受了它。感謝您的解決方案。 – Daniel

+0

你有什麼版本的Xcode? –

回答

2

至少有一個問題是,你正在運行RVM,但使用sudo到您的系統上安裝的寶石。

讀「RVM and RubyGems」,尤其是部分,上面寫着:

「不使用sudo的......」

RVM你在創建一個沙箱中,用戶在自己的用戶空間機器,它允許你管理它,而不需要成爲系統管理員。換句話說,這意味着您不必爲任何RVM或寶石管理使用sudo

如果你使用sudo,你暫時停止被你的用戶,併成爲管理員,具有管理員權限和管理員的環境,這確實不包括/Users/daniel/.rvm/rubies/ruby-1.9.3-p286路徑RVM沙箱。沙箱的知識由您的環境中的PATH攜帶,而您的機器上的根並不使用該PATH。安裝在sudo子shell中的Gems會安裝到管理員帳戶知道​​的位置,該位置位於System Ruby安裝中,這就是您的RVM沙盒化Ruby無法看到的原因:系統的Ruby和系統之間沒有交叉您的RVM控制的RUby。這就是沙箱的全部理念:分離要素和資源以避免污染。

你本來可以通過查看輸出全力以赴想通這一點:

which ruby irb gem rake 

的路徑,他們都指向您的沙箱:

/Users/daniel/.rvm/rubies 

在Mac OS系統,該命令應報告:

/usr/bin/ruby 
/usr/bin/irb 
/usr/bin/gem 
/usr/bin/rake 

重新安裝Rails和SQLite寶石使用:

gem install rails sqlite3 

並查看您的包的行爲。

順便說一下,不要使用sudo故意嘗試管理/刪除系統安裝的Ruby。 Apple爲了自己的目的安裝了這些軟件,以啓用他們安裝的軟件。利用它的存在是可以的,但它的存在是爲了它們的使用。爲了您自己的目的使用RVM管理的Ruby。

+1

謝謝你的答案!我自己解決了這個問題。安裝therubyracer版本0.10.2後,命令「bundle install」運行良好。再次感謝你們! – Daniel

+0

這裏同樣的問題。我不得不將版本的libv8更改爲3.3.10,並將therubyracer更改爲0.10.2。 – Prcela