【问题标题】:how do I install ruby-debug in ruby 1.9.3 / Rails 3.2.1 [duplicate]如何在 ruby​​ 1.9.3 / Rails 3.2.1 中安装 ruby​​-debug [重复]
【发布时间】:2012-02-03 00:46:53
【问题描述】:

可能重复:
Rails 3.1 and Ruby 1.9.3p125: ruby-debug19 still crashes with “Symbol not found: _ruby_threadptr_data_type”

我已经完成了打印到控制台的工作——我想进入 20 世纪并开始使用调试器!!但是如何安装 ruby​​-debug?当我尝试安装 ruby​​-debug19 gem 时,ruby-debug.c 的本机编译失败。我查看了其他 SO 帖子,但尚未找到答案...

  • 我正在使用 Ruby 1.9.3-p0
  • 我使用的是 Rails 3.2(当然是 Gemfile)
  • 我没有使用 RVM - 相反,我有一个包含所有可执行文件、gem、源等的完全沙盒目录。我在下面将其称为 $SANDBOX...

捆绑安装不起作用

如果我将 ruby​​-debug19 添加到我的 Gemfile 并执行 bundle install,它会在使用 conflicting types for 'rb_iseq_compile_with_option' 构建期间失败:

# file: Gemfile
...
group :development do
  gem 'ruby-debug19'
end
...

% bundle install
...
Installing ruby-debug-base19 (0.11.25) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
        /Users/r/Developer/Topaz/usr/bin/ruby extconf.rb 
...
ruby_debug.c:29: error: conflicting types for 'rb_iseq_compile_with_option'
$SANDBOX/usr/include/ruby-1.9.1/ruby-1.9.3-p0/vm_core.h:505: error: previous declaration of 'rb_iseq_compile_with_option' was here
...
make: *** [ruby_debug.o] Error 1

从命令行安装 ruby​​-debug 不起作用

如果我尝试从命令行构建 gem,使用指向当前 ruby​​ 的 include 目录的 --with-ruby-include 参数,我会得到同样的错误:

% gem install ruby-debug19 -- --with-ruby-include=$SANDBOX/packages/ruby-1.9.3-p0
Building native extensions.  This could take a while...
ERROR:  Error installing ruby-debug19:
        ERROR: Failed to build gem native extension.

        $SANDBOX/usr/bin/ruby extconf.rb --with-ruby-include=$SANDBOX/packages/ruby-1.9.3-p0/include
checking for rb_method_entry_t.body in method.h... no
checking for vm_core.h... yes
checking for iseq.h... yes
checking for insns.inc... yes
checking for insns_info.inc... yes
checking for eval_intern.h... yes
creating Makefile

make
compiling breakpoint.c
compiling ruby_debug.c
ruby_debug.c:29: error: conflicting types for 'rb_iseq_compile_with_option'
$SANDBOX/usr/include/ruby-1.9.1/ruby-1.9.3-p0/vm_core.h:505: error: previous declaration of 'rb_iseq_compile_with_option' was here

我错过了什么?

--with-ruby-include 是否期待不同的东西?当前的 ruby​​-debug19 坏了吗?

【问题讨论】:

标签: ruby-on-rails ruby gem ruby-debug


【解决方案1】:

感谢@Marc Talbot 在 OP 中的评论,我找到了一个有效的食谱。

从 RubyForge 下载 linecache19 和 ruby​​-debug-base19:

% curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
% curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem

编译这两个gem

% gem install linecache19-0.5.13.gem
Building native extensions.  This could take a while...
Successfully installed linecache19-0.5.13
1 gem installed
...
% gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=$SANDBOX/packages/ruby-1.9.3-p0
Building native extensions.  This could take a while...
Successfully installed ruby-debug-base19-0.11.26
1 gem installed
...

更新您的 Gemfile

# file: Gemfile
...
group :development do
  gem 'linecache19', '0.5.13'
  gem 'ruby-debug-base19', '0.11.26'
  gem 'ruby-debug19', :require => 'ruby-debug'
end

捆绑安装和测试调试器

% bundle install
Fetching source index for http://rubygems.org/
...
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
% irb
irb(main):001:0> require 'ruby-debug'
=> true
irb(main):002:0> debugger
$SANDBOX/usr/lib/ruby/1.9.1/irb/context.rb:166
@last_value = value
(rdb:1) p 'hooray'
"hooray"

希望这对其他人有所帮助。

【讨论】:

  • 这些步骤对我有用。但是,要通过 IDE(如 Netbeans)完成这项工作,您需要在之后执行 gem install --ignore-dependencies -v 0.4.12 ruby-debug-ide19
  • 此方法在 Windows 7 中也适用于我。如果您没有 curl,您可以复制这些 gem url 并将其粘贴到网络浏览器中以下载它。然后在执行gem install之前将目录切换到下载路径。我不得不将--with-ruby-include=$SANDBOX/packages/ruby-1.9.3-p0 更改为<MY_RUBY_INSTALLATION_PATH>/include/ruby-1.9.1/ruby-1.9.3-p<RELEASE_NUMBER>
  • 我刚刚从另一个 SO 讨论中读到,不再积极维护 ruby​​-debug19。见:stackoverflow.com/questions/1083451/debugging-in-ruby-1-9建议使用新的调试器gem:github.com/cldwalker/debugger
  • group :deployment do gem 'linecache19', '0.5.13' gem 'ruby-debug-base19x', '>= 0.11.30.pre10' gem 'ruby-debug19', :require = > 'ruby-debug' 结束
【解决方案2】:

(根据您的日志,我假设您使用的是 Linux,特别是 Debian 发行版) 有一个简单的解决方案: 在外壳中,

sudo apt-get install ruby-dev1.9.3

注意:我实际上不知道是否有一个名为ruby-dev1.9.3的包,因为我为1.9.2安装了ruby-dev,它是ruby-dev1.9(我想。那是前一段时间。如果有人知道它们是什么,请评论)。

此包安装解释器的 C 扩展所需的标头 (ruby.h)。

【讨论】:

  • FWIW,我在 Mac OS X 10.6.8 上,所以我不使用 apt-get。我从ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz 下载并编译了我的 ruby​​ 源代码。我未解压的源代码树包含 include/ruby.h 和 include/ruby/ruby.h。
  • 对我来说关键是 linecache19 v0.5.13
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-02-18
  • 1970-01-01
  • 1970-01-01
  • 2012-11-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多