【问题标题】:ruby-debug install error: failed to build gem native extensionruby-debug 安装错误:构建 gem 原生扩展失败
【发布时间】:2010-10-31 11:37:13
【问题描述】:

我正在使用 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$ 

【问题讨论】:

  • 您的问题解决了吗?使用 1.9.2-head 时我也遇到此错误 - 1.9.2 的早期版本似乎没有问题

标签: ruby-on-rails


【解决方案1】:

这里的问题可能是安装脚本无法通过网络获取 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 在以下链接中帮助解决了这个问题

【讨论】:

  • 这也适用于非 rvm 安装,只需更改 --with-ruby-include= 值以指向源的提取副本。 (在某些环境中,您可能需要以 sudo 身份运行。)
  • 有Windows的解决方案吗?
  • 所以你必须先安装 ruby​​ 1.9.2 版?
【解决方案2】:

ruby-debug gem 与 Ruby 1.9.2 不兼容。你需要使用 gem ruby​​-debug19

所以改变你的 Gemfile 来使用这个

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/

    【讨论】:

      【解决方案4】:

      我在防火墙后面的 vpn 中工作并设置了 http_proxy 环境变量时遇到了类似的问题(编译本机扩展的问题)。此案例安装程序无法检索 ruby​​ tar 文件。 我关闭了 vpn 并取消设置 http_proxy 变量,然后成功安装了 gem。 我认为 --with-ruby-include 是另一种选择。

      【讨论】:

        【解决方案5】:

        由于使用 cntlm 代理的连接问题,安装 gem ruby​​-debug-base19x 也失败了,并且“--with-ruby-include”对我不起作用。在没有代理的情况下安装 gem 很顺利。

        【讨论】:

          【解决方案6】:

          ruby-debug gem 与 Ruby 1.9.2 及更高版本不兼容。 用以下替换 gem 'ruby-debug19' 你需要使用 gem ruby​​-debug19 所以改变你的 Gemfile 来使用这个

          gem 'ruby-debug19'

          【讨论】:

            【解决方案7】:

            对于 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 移动到上面的包含目录中。

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

            【讨论】:

              【解决方案8】:

              就用这个吧:

              [sudo] gem update --system 
              

              解决方案来自http://rubygems.org/pages/download

              【讨论】:

                猜你喜欢
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 2014-09-18
                • 2020-07-21
                • 1970-01-01
                • 1970-01-01
                • 2015-06-27
                • 2012-11-02
                相关资源
                最近更新 更多