【问题标题】:bundle install doesn't work on with RVM捆绑安装不适用于 RVM
【发布时间】:2013-01-17 19:48:56
【问题描述】:

我在安装包时遇到问题。

这是我最后的步骤:

  • 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

【问题讨论】:

  • 您接受 XCode 许可协议了吗?
  • 我可以启动 XCode 并创建新项目等。所以我接受了它。感谢您的解决方案。
  • 你有什么版本的 Xcode?​​span>
  • 你使用的是什么版本的 libv8?
  • 我注意到,我不使用 libv8:

标签: ruby macos git bundle-install


【解决方案1】:

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

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

“不要使用 sudo...”

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

如果您确实使用了sudo,您将暂时不再是用户,而是成为管理员,拥有管理员权限和管理员环境,这在您的 @ 中包含 RVM 沙箱987654325@ 路径。沙箱的知识由您环境中的 PATH 携带,您机器上的 root 不使用它。安装在 sudo 子 shell 内的 Gem 被安装到管理员帐户知道​​的位置,即 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 用于您自己的目的。

【讨论】:

  • 感谢您的所有回答!我自己解决了这个问题。安装 ruby​​racer 0.10.2 版后,“bundle install”命令运行良好。再次感谢大家!
  • 这里有同样的问题。我不得不将 libv8 的版本更改为 3.3.10,并将 therubyracer 的版本更改为 0.10.2。
猜你喜欢
  • 2023-04-03
  • 1970-01-01
  • 2013-10-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-11
  • 2019-06-17
相关资源
最近更新 更多