如何在 ruby 1.9.3 / Rails 3.2.1 中安装 ruby-debug
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9122232/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how do I install ruby-debug in ruby 1.9.3 / Rails 3.2.1
提问by fearless_fool
Possible Duplicate:
Rails 3.1 and Ruby 1.9.3p125: ruby-debug19 still crashes with “Symbol not found: _ruby_threadptr_data_type”
可能的重复:
Rails 3.1 和 Ruby 1.9.3p125:ruby-debug19 仍然崩溃并显示“Symbol not found: _ruby_threadptr_data_type”
I'm done with printing to the console -- I want to move up to the 20th century and start using a debugger!! But how do I install ruby-debug? The native compilation of ruby-debug.cfails when I try to install the ruby-debug19 gem. I've looked over other SO postings and haven't found the answer yet...
我已经完成了打印到控制台的工作——我想进入 20 世纪并开始使用调试器!!但是如何安装 ruby-debug 呢?ruby-debug.c当我尝试安装 ruby-debug19 gem 时,本机编译失败。我查看了其他 SO 帖子,但还没有找到答案......
- I am using Ruby 1.9.3-p0
- I am using Rails 3.2 (with Gemfile, of course)
- I am NOT using RVM -- instead, I have a fully sandboxed directory containing all executables, gems, sources, etc. I refer to it as $SANDBOX below...
- 我正在使用 Ruby 1.9.3-p0
- 我正在使用 Rails 3.2(当然还有 Gemfile)
- 我没有使用 RVM——相反,我有一个完全沙盒化的目录,其中包含所有可执行文件、gems、源代码等。我在下面将其称为 $SANDBOX...
bundle install doesn't work
捆绑安装不起作用
If I add ruby-debug19 to my Gemfile and do bundle install, it fails during build with conflicting types for 'rb_iseq_compile_with_option':
如果我将 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
gem install ruby-debug from the command line doesn't work
从命令行 gem install ruby-debug 不起作用
If I try building the gem from the command line, using the --with-ruby-include argument pointing at the includedirectory for the current ruby, I get the same error:
如果我尝试从命令行构建 gem,使用 --with-ruby-include 参数指向include当前 ruby的目录,我会得到同样的错误:
% 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
what am I missing?
我错过了什么?
Is --with-ruby-include expecting something different? Is the current ruby-debug19 broken?
--with-ruby-include 期待不同的东西吗?当前的 ruby-debug19 是否已损坏?
回答by fearless_fool
Thanks to @Marc Talbot's comment in the OP, I found a working recipe.
感谢@Marc Talbot 在 OP 中的评论,我找到了一个有效的食谱。
download linecache19 and ruby-debug-base19 from RubyForge:
从 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
compile the two gems
编译两个 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
...
update your Gemfile
更新你的 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 and test the debugger
捆绑安装并测试调试器
% 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"
Hopefully this will help others.
希望这会帮助其他人。
回答by Linuxios
(From your logs, I assume you are on Linux, specifically a Debian distro) There is a simple solution to this: In the shell,
(根据您的日志,我假设您使用的是 Linux,特别是 Debian 发行版)对此有一个简单的解决方案:在 shell 中,
sudo apt-get install ruby-dev1.9.3
Note: I don't actually know if there is a package called ruby-dev1.9.3, because I installed ruby-devfor 1.9.2, which was ruby-dev1.9(I think. That was a while ago. If anyone knows what they are, please comment).
注意:我实际上不知道是否有一个名为 的包ruby-dev1.9.3,因为我是ruby-dev为 1.9.2安装的,它是ruby-dev1.9(我认为。那是前一段时间。如果有人知道它们是什么,请发表评论)。
This package installs the headers that the C extensions to the interpreter need (ruby.h).
此包安装解释器的 C 扩展所需的头文件 ( ruby.h)。

