3

我目前在 Windows XP 32 位机器上运行 Ruby 1.9.2p0。自从我们升级到 Ruby 1.9 后,我根本无法进行任何形式的调试。有人告诉我,您需要新的 ruby​​-debug19 gem 才能运行。问题是,我公司的代理阻止 gem 依赖管理器连接外部存储库。没关系,我自己下载 gem 本地安装。结果:

ERROR:  Error installing ruby-debug19-0.11.6.gem:
    ERROR: Failed to build gem native extension.

C:/Ruby192/bin/ruby.exe extconf.rb --with-ruby-include=C:\Ruby192\include
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=C:/Ruby192/bin/ruby
    --with-ruby-dir
    --without-ruby-dir
    --with-ruby-include=${ruby-dir}/include
    --with-ruby-lib
    --without-ruby-lib=${ruby-dir}/lib
C:/Ruby192/lib/ruby/1.9.1/net/http.rb:644:in `initialize': A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. - connect(2) (Errno::ETIMEDOUT)
    from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:644:in `open'
    from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:644:in `block in connect'
    from C:/Ruby192/lib/ruby/1.9.1/timeout.rb:44:in `timeout'
    from C:/Ruby192/lib/ruby/1.9.1/timeout.rb:87:in `timeout'
    from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:644:in `connect'
    from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:637:in `do_start'
    from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:626:in `start'
    from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:1160:in `request'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/ruby_core_source-0.1.4/lib/contrib/uri_ext.rb:239:in `block in read'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/ruby_core_source-0.1.4/lib/contrib/uri_ext.rb:286:in `connect'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/ruby_core_source-0.1.4/lib/contrib/uri_ext.rb:234:in `read'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/ruby_core_source-0.1.4/lib/contrib/uri_ext.rb:128:in `download'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/ruby_core_source-0.1.4/lib/ruby_core_source.rb:55:in `block in create_makefile_with_core'
    from C:/Ruby192/lib/ruby/1.9.1/tempfile.rb:320:in `open'
    from C:/Ruby192/lib/ruby/gems/1.9.1/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-p0.tar.gz


Gem files will remain installed in C:/Ruby192/lib/ruby/gems/1.9.1/gems/linecache19-0.5.11 for inspection.
Results logged to C:/Ruby192/lib/ruby/gems/1.9.1/gems/linecache19-0.5.11/ext/trace_nums/gem_make.out

也许我做出了不合理的假设,因为我对 Ruby 还很陌生,但看起来安装脚本正在尝试连接外部存储库以获取某些东西。如果是这样,这很荒谬,如果我能够使用管理器自动安装gem,为什么还要在本地安装gem?有人知道我可以以纯本地离线方式安装调试器的方法吗?我很感激任何帮助。

4

8 回答 8

8

我遇到了完全相同的问题,我第二次 Luis Lavena - 只需将所有 *.h 和 *.inc 文件从您的 ruby​​ 源复制到此命令打印出的目录中:

ruby -rmkmf -e 'puts Config::CONFIG["rubyhdrdir"] + "/" + "ruby-" + RUBY_VERSION.to_s + "-p" + RUBY_PATCHLEVEL.to_s'

然后 ruby​​_core_source 将找到这些并愉快地继续安装。

于 2010-11-13T10:39:37.787 回答
3

我以前也遇到过同样的问题,尽管我没有代理。也许这个解决方案会有所帮助。ruby-debug19宝石依赖于linecache19and ruby-debug-base19(以及 Luis 提到的其他一些)。不确定后者,但前者没有附带 Windows 的二进制文件,这是我问题的根源。为了在本地正确安装,您应该将 gems 下载到一个目录,然后gem install -l像您可能所做的那样执行。所有必要的 gem 都可以从这里下载。

由于 linecache19 不附带 win32 二进制文件,它会尝试通过编译源代码来“构建原生扩展”。这将在大多数 Windows 计算机上失败,除非您有 VC6 编译器,或者通过此链接安装了开发工具包。该软件包要求您使用ruby​​ 安装程序来安装 ruby​​ for windows。一旦安装了开发工具包,您就不应该在“构建本机扩展”时遇到故障。

您可以在此处阅读简短的概述。

希望这可以帮助..

于 2010-11-15T06:27:11.247 回答
1

我使用 exe 安装程序安装了 ruby​​ 1.9.3。但我发现了如何让这件事发挥作用。我打开了名为“ ruby_core.rb”的文件。因为错误就在那里。

我发现这部分代码无法下载源代码。

  #
  # Download the headers
  #
  uri_path = "http://ftp.ruby-lang.org/pub/ruby/1.9/" + ruby_dir + ".tar.gz"
  Tempfile.open("ruby-src") { |temp|

    temp.binmode
    uri = URI.parse(uri_path)
    uri.download(temp)

    tgz = Zlib::GzipReader.new(File.open(temp, "rb"))

    FileUtils.mkdir_p(dest_dir)
    Dir.mktmpdir { |dir|
      inc_dir = dir + "/" + ruby_dir + "/*.inc"
      hdr_dir = dir + "/" + ruby_dir + "/*.h"
      Archive::Tar::Minitar.unpack(tgz, dir)
      FileUtils.cp(Dir.glob([ inc_dir, hdr_dir ]), dest_dir)
    }
  }

所以我从那里得到了链接,手动创建了应该在“ ruby_dir”变量内的目录,并通过该链接下载了所有源。

为了找出这个目录的名称,我从顶部剪切了几个代码字符串,并通过控制台使用 IRB 运行它。

      inc_dir = dir + "/" + ruby_dir + "/*.inc"
      hdr_dir = dir + "/" + ruby_dir + "/*.h"

所以你们都需要检查 dir (提到的地方的完整路径)和 ruby​​_dir 来为所有源创建一个目录。

祝你好运!

于 2012-02-01T06:15:06.117 回答
1

如果您使用 RVM,

你可以考虑看看这个 URL:- http://isitruby19.com/linecache19

为我工作..

还,

在某个阶段,我什至不得不手动下载 gems 并使用带有“-l”命令的 gem install 来让事情正常工作..相同的命令是..

mohnish@mohnish-desktop:~/Downloads/Diaspora_new_gems/mar10$ gem install ruby-debug19-0.11.6.gem -l -- --with-ruby-include=$rvm_path/src/ruby-1.9.2-p180/
Building native extensions.  This could take a while...
Successfully installed linecache19-0.5.12
Successfully installed ruby-debug19-0.11.6
2 gems installed
Installing ri documentation for linecache19-0.5.12...
Installing ri documentation for ruby-debug19-0.11.6...
Installing RDoc documentation for linecache19-0.5.12...
Installing RDoc documentation for ruby-debug19-0.11.6...
mohnish@mohnish-desktop:~/Downloads/Diaspora_new_gems/mar10$ ls

mohnish@mohnish-desktop:~/Downloads/Diaspora_new_gems/mar10$ gem install ruby-debug-base19-0.11.25.gem -l -- --with-ruby-include=$rvm_path/src/ruby-1.9.2-p180/. 
Building native extensions.  This could take a while...
Successfully installed ruby-debug-base19-0.11.25
1 gem installed
Installing ri documentation for ruby-debug-base19-0.11.25...
Installing RDoc documentation for ruby-debug-base19-0.11.25...
mohnish@mohnish-desktop:~/Downloads/Diaspora_new_gems/mar10$ 

根据您的 Ruby 版本(136、180 或..)进行适当更改。我刚刚添加了一个类似的安装 wrt 另一个 gem ruby​​-debug-base19-0.11.25,以供参考。

于 2011-04-12T08:32:00.260 回答
1

Ruby 1.9 的 ruby​​-debug 使用了 Ruby 1.9 的某些特性,该特性未在普通头文件中公开(内部)

因此,ruby-debug 将尝试下载与您的 Ruby 版本匹配的源包,并在编译阶段提取这些头文件。

我同意这是荒谬的,但由于它使用了 Ruby 内部标头的某些未记录的特性,所以没有办法。

这是由 ruby​​_core_source gem 触发的,您可以在此处检查其源代码

我建议您使用浏览器下载您的 Ruby 版本的确切补丁级别(在上面提供的输出中指示)并查看 ruby​​_core_source 操作,在指示的位置提取头文件,请参阅ruby​​_core_source.rb 的第 38 行

于 2010-11-12T21:57:06.223 回答
0

这对我有用

$ echo $rvm_path/src/$(rvm tools strings) 
$ rvm @global gem install ruby-debug19 -- --with-ruby-include=$rvm_path/src/$(rvm tools strings)

感谢http://isitruby19.com/linecache19

于 2011-12-27T10:03:42.167 回答
0

OSX 10.6.8 和 rvm 发生在我身上,本页下面的答案只是
gem install ruby-debug19 -- --with-ruby-include=$rvm_path/src/ruby-1.9.2-p180/
将 ruby​​-1.9.2... 更改为您正在使用的任何ruby

于 2011-07-19T11:58:18.167 回答
0

Gem 确实支持代理。您可能会摆弄这两个参数:

        --source URL 使用 URL 作为 gems 的远程源
    -p, --[no-]http-proxy [URL] 使用 HTTP 代理进行远程操作
于 2010-11-12T23:25:15.577 回答