捆绑安装不适用于RVM

时间:2013-01-17 19:48:57

标签: ruby macos git bundle-install

我在安装捆绑包时遇到问题。

这是我的最后一步:

  • 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

1 个答案:

答案 0 :(得分:2)

至少有一个问题是您正在运行RVM,但使用sudo在您的系统上安装gem。

阅读“RVM and RubyGems”,特别是说:

的部分

“不要使用sudo ......”

RVM为您(即用户)在您自己的计算机用户空间中创建一个沙箱,使您无需成为系统管理员即可对其进行管理。换句话说,这意味着您不必使用sudo进行任何RVM或宝石管理。

如果您使用sudo,您暂时不再是您,用户并成为管理员,具有管理员权限和管理员环境, NOT 包含RVM沙箱你的/Users/daniel/.rvm/rubies/ruby-1.9.3-p286路径。沙箱的知识由您的环境中的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:

gem install rails sqlite3

并查看您的捆绑包的行为方式。

顺便说一句,不要使用sudo故意尝试管理/删除系统安装的Ruby。这是Apple为了自己的目的而安装的,用于启用他们安装的软件。利用它的存在是可以的,但它可供它们使用。使用RVM管理的Ruby用于您自己的目的。