2013-01-17 111 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