1

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

这些是我的最后一步:

  • 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
4

1 回答 1

2

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

阅读“ RVM and RubyGems ”,尤其是上面写着的部分:

“不要使用 sudo ...”

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

如果您确实使用sudo,您将暂时不再是您(用户),并成为管理员,拥有管理员权限和管理员环境,其中不包括您的/Users/daniel/.rvm/rubies/ruby-1.9.3-p286路径中的 RVM 沙箱。沙箱的知识由您环境中的 PATH 携带,您机器上的 root 不使用它。安装在该子 shell 中的 Gemsudo会安装到管理员帐户知道​​的位置,即 System Ruby 安装中,这就是您的 RVM 沙盒 Ruby 看不到它们的原因:系统的 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 用于您自己的目的。

于 2013-01-18T15:39:28.683 回答