Ruby-debug安装错误:构建本地扩展宝石失败。

36

我正在使用Rails 3和1.9.2版本。

我使用了rvm。

我执行了以下操作:

sudo gem install ruby-gem

并获得:

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

/Users/blankman/.rvm/rubies/ruby-1.9.2-head/bin/ruby extconf.rb
Can't handle 1.9.x yet
*** 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/blankman/.rvm/rubies/ruby-1.9.2-head/bin/ruby


Gem files will remain installed in /Users/blankman/.rvm/gems/ruby-1.9.2-head/gems/linecache-0.43 for inspection.
Results logged to /Users/blankman/.rvm/gems/ruby-1.9.2-head/gems/linecache-0.43/ext/gem_make.out

更新

新增:

gem 'ruby-debug19'

当运行bundle install时,我收到以下信息:

Fetching source index for http://rubygems.org/
Using rake (0.8.7) 
Using abstract (1.0.0) 
Using activesupport (3.0.0.rc2) 
Using builder (2.1.2) 
Using i18n (0.4.1) 
Using activemodel (3.0.0.rc2) 
Using erubis (2.6.6) 
Using rack (1.2.1) 
Using rack-mount (0.6.13) 
Using rack-test (0.5.6) 
Using tzinfo (0.3.23) 
Using actionpack (3.0.0.rc2) 
Using mime-types (1.16) 
Using polyglot (0.3.1) 
Using treetop (1.4.8) 
Using mail (2.2.7) 
Using actionmailer (3.0.0.rc2) 
Using arel (1.0.1) 
Using activerecord (3.0.0.rc2) 
Using activeresource (3.0.0.rc2) 
Using archive-tar-minitar (0.5.2) 
Using bundler (1.0.3) 
Using columnize (0.3.1) 
Using ruby_core_source (0.1.4) 
Installing linecache19 (0.5.11) with native extensions /Users/blankman/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/rubygems/installer.rb:483:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

/Users/blankman/.rvm/rubies/ruby-1.9.2-head/bin/ruby extconf.rb 
checking for vm_core.h... no
checking for vm_core.h... no
*** 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/blankman/.rvm/rubies/ruby-1.9.2-head/bin/ruby
    --with-ruby-dir
    --without-ruby-dir
    --with-ruby-include
    --without-ruby-include=${ruby-dir}/include
    --with-ruby-lib
    --without-ruby-lib=${ruby-dir}/lib
/Users/blankman/.rvm/gems/ruby-1.9.2-head@hz/gems/ruby_core_source-0.1.4/lib/contrib/uri_ext.rb:268:in `block (2 levels) in read': Looking for http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p14.tar.gz and all I got was a 404! (URI::NotFoundError)
    from /Users/blankman/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/net/http.rb:1186:in `block in transport_request'
    from /Users/blankman/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/net/http.rb:2334:in `reading_body'
    from /Users/blankman/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/net/http.rb:1185:in `transport_request'
    from /Users/blankman/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/net/http.rb:1169:in `request'
    from /Users/blankman/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/net/http.rb:1162:in `block in request'
    from /Users/blankman/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/net/http.rb:627:in `start'
    from /Users/blankman/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/net/http.rb:1160:in `request'
    from /Users/blankman/.rvm/gems/ruby-1.9.2-head@hz/gems/ruby_core_source-0.1.4/lib/contrib/uri_ext.rb:239:in `block in read'
    from /Users/blankman/.rvm/gems/ruby-1.9.2-head@hz/gems/ruby_core_source-0.1.4/lib/contrib/uri_ext.rb:286:in `connect'
    from /Users/blankman/.rvm/gems/ruby-1.9.2-head@hz/gems/ruby_core_source-0.1.4/lib/contrib/uri_ext.rb:234:in `read'
    from /Users/blankman/.rvm/gems/ruby-1.9.2-head@hz/gems/ruby_core_source-0.1.4/lib/contrib/uri_ext.rb:128:in `download'
    from /Users/blankman/.rvm/gems/ruby-1.9.2-head@hz/gems/ruby_core_source-0.1.4/lib/ruby_core_source.rb:55:in `block in create_makefile_with_core'
    from /Users/blankman/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/tempfile.rb:320:in `open'
    from /Users/blankman/.rvm/gems/ruby-1.9.2-head@hz/gems/ruby_core_source-0.1.4/lib/ruby_core_source.rb:51:in `create_makefile_with_core'
    from extconf.rb:20:in `<main>'
Requesting http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p14.tar.gz


Gem files will remain installed in /Users/blankman/.rvm/gems/ruby-1.9.2-head@hz/gems/linecache19-0.5.11 for inspection.
Results logged to /Users/blankman/.rvm/gems/ruby-1.9.2-head@hz/gems/linecache19-0.5.11/ext/trace_nums/gem_make.out
    from /Users/blankman/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/rubygems/installer.rb:486:in `block in build_extensions'
    from /Users/blankman/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/rubygems/installer.rb:446:in `each'
    from /Users/blankman/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/rubygems/installer.rb:446:in `build_extensions'
    from /Users/blankman/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/rubygems/installer.rb:198:in `install'
    from /Users/blankman/.rvm/gems/ruby-1.9.2-head@global/gems/bundler-1.0.3/lib/bundler/source.rb:100:in `install'
    from /Users/blankman/.rvm/gems/ruby-1.9.2-head@global/gems/bundler-1.0.3/lib/bundler/installer.rb:55:in `block in run'
    from /Users/blankman/.rvm/gems/ruby-1.9.2-head@global/gems/bundler-1.0.3/lib/bundler/spec_set.rb:12:in `block in each'
    from /Users/blankman/.rvm/gems/ruby-1.9.2-head@global/gems/bundler-1.0.3/lib/bundler/spec_set.rb:12:in `each'
    from /Users/blankman/.rvm/gems/ruby-1.9.2-head@global/gems/bundler-1.0.3/lib/bundler/spec_set.rb:12:in `each'
    from /Users/blankman/.rvm/gems/ruby-1.9.2-head@global/gems/bundler-1.0.3/lib/bundler/installer.rb:44:in `run'
    from /Users/blankman/.rvm/gems/ruby-1.9.2-head@global/gems/bundler-1.0.3/lib/bundler/installer.rb:8:in `install'
    from /Users/blankman/.rvm/gems/ruby-1.9.2-head@global/gems/bundler-1.0.3/lib/bundler/cli.rb:221:in `install'
    from /Users/blankman/.rvm/gems/ruby-1.9.2-head@global/gems/bundler-1.0.3/lib/bundler/vendor/thor/task.rb:22:in `run'
    from /Users/blankman/.rvm/gems/ruby-1.9.2-head@global/gems/bundler-1.0.3/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
    from /Users/blankman/.rvm/gems/ruby-1.9.2-head@global/gems/bundler-1.0.3/lib/bundler/vendor/thor.rb:246:in `dispatch'
    from /Users/blankman/.rvm/gems/ruby-1.9.2-head@global/gems/bundler-1.0.3/lib/bundler/vendor/thor/base.rb:389:in `start'
    from /Users/blankman/.rvm/gems/ruby-1.9.2-head@global/gems/bundler-1.0.3/bin/bundle:13:in `<top (required)>'
    from /Users/blankman/.rvm/gems/ruby-1.9.2-head@global/bin/bundle:19:in `load'
    from /Users/blankman/.rvm/gems/ruby-1.9.2-head@global/bin/bundle:19:in `<main>'
blankmans-MacBook-Pro:hz blankman$ 

2
你解决了你的问题吗?当我使用1.9.2-head时,我也遇到了这个错误 - 早期版本的1.9.2似乎没有问题。 - Tadas T
8个回答

50

这里的问题可能是安装脚本要在网络上获取Ruby头文件(以便构建调试器gem),但却找不到你所需的Ruby特定补丁级别的头文件。这就是输出行中发生的情况。

Looking for http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p14.tar.gz and all I got was a 404! (URI::NotFoundError)

作为一种解决方案,您可以将指针指向您的本地 Ruby 源代码副本,rvm 已经使用它来在您的计算机上构建 Ruby。下面是具体步骤...

gem install ruby-debug19 -- --with-ruby-include=$rvm_path/src/ruby-1.9.2-head/

感谢以下链接中的Dirk帮助解决了这个问题


1
这对于非rvm安装也适用,只需将--with-ruby-include=的值更改为指向源代码的提取副本即可。(在某些环境中可能需要以sudo身份运行。) - Brian Glick
3
有没有针对Windows的解决方案? - Chris
那么你首先必须安装 Ruby 版本 1.9.2 吗? - tread

14

ruby-debug gem不兼容Ruby 1.9.2,您需要使用ruby-debug19 gem。

因此,请在您的Gemfile中更改以使用此gem。

gem 'ruby-debug19'

3
在你的Gemfile中,将ruby-debug行更改为以下内容:
gem 'ruby-debug19', :require => 'ruby-debug'

我的参考来源是http://dirk.net/2010/04/17/ruby-debug-with-ruby-19x-and-rails-3-on-rvm/

这篇文章介绍了如何在 RVM 中使用 Ruby 1.9.x 和 Rails 3 进行调试。它提供了几个步骤来配置 gem,安装必要的包和使用 ruby-debug。跟随这些步骤,你就可以轻松地开始在 Ruby on Rails 应用程序中进行调试。

1
对于Windows系统,搜索你的Ruby目录中的 vm_core.h 文件,并将该目录用作包含路径。对我而言,这个目录是:
gem install ruby-debug-base19 -- --with-ruby-include=C:\JRuby\lib\native\include\ruby-1.9.3-p392

然后我不得不检查:
C:\JRuby\lib\ruby\gems\shared\gems\linecache19-0.5.12\ext\trace_nums\gem_make.out

将ruby/ruby.h移动到上面的include目录中。

现在我有一些其他错误,稍后再修复它...


0

安装 gem ruby-debug-base19x 也因使用 cntlm 代理出现连接问题而失败,而对于我来说 "--with-ruby-include" 也没有起作用。在没有代理的情况下安装 gem 进行得很顺利。


0

ruby-debug gem不兼容Ruby 1.9.2及以上版本。 请使用以下替代品gem 'ruby-debug19' 您需要使用ruby-debug19 gem,因此请在您的Gemfile中进行更改以使用它

gem 'ruby-debug19'


0

我曾经遇到过类似的问题(编译本地扩展时出现问题),当时我在防火墙后面使用 VPN,并设置了 http_proxy 环境变量。由于这种情况下安装程序无法获取 Ruby tar 文件,因此我关闭了 VPN 并取消了 http_proxy 变量,然后成功安装了 gem。我认为 --with-ruby-include 是一种替代方案。


-1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接