Ruby on rails 如何在ruby 1.9.3/Rails 3.2.1中安装ruby调试

Ruby on rails 如何在ruby 1.9.3/Rails 3.2.1中安装ruby调试,ruby-on-rails,ruby,gem,ruby-debug,Ruby On Rails,Ruby,Gem,Ruby Debug,可能重复: 我已经完成了向控制台的打印--我想进入20世纪并开始使用调试器!!但是如何安装ruby调试?当我尝试安装ruby-debug19 gem时,ruby debug.c的本机编译失败。我已经看过其他的SO帖子,还没有找到答案 我使用的是Ruby 1.9.3-p0 我使用的是Rails 3.2(当然是Gemfile) 我没有使用RVM——相反,我有一个完全沙盒的目录,其中包含所有可执行文件、gem、源等等。我在下面将其称为$SANDBOX 捆绑安装不起作用 如果我将ruby-debu

可能重复:

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

  • 我使用的是Ruby 1.9.3-p0
  • 我使用的是Rails 3.2(当然是Gemfile)
  • 我没有使用RVM——相反,我有一个完全沙盒的目录,其中包含所有可执行文件、gem、源等等。我在下面将其称为$SANDBOX
捆绑安装不起作用 如果我将ruby-debug19添加到我的Gemfile中并进行
捆绑安装
,它在生成过程中会失败,因为“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从命令行安装ruby调试不起作用 如果我尝试从命令行构建gem,使用--with ruby include参数指向当前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
我错过了什么? 对于ruby,include是否期望有所不同?当前的ruby-debug19是否已损坏?

(根据您的日志,我假设您使用的是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
)。

多亏了@Marc Talbot在OP中的评论,我找到了一个有效的方法

从RubyForge下载linecache19和ruby-debug-base19: 编译这两个宝石 更新你的文件 捆绑安装并测试调试器
希望这能对其他人有所帮助。

谷歌搜索表明很多人对1.9.3上的调试器有问题。似乎有一些黑客可以让它工作:@Marc:在这两个链接之间,我让它工作了。请看下面我的答案。嗨@casperOne——只是好奇:这个问题是在发布之前发布的——根据常见问题解答,应该是那个问题以重复的形式关闭吗?@fearless不,发布时间并不决定哪个问题是另一个问题的副本。有一个更好的选择。请看FWIW,我在Mac OS X 10.6.8上,所以我不使用apt get。我从下载并编译了我的ruby源代码。我的非tar源代码树有include/ruby.h和include/ruby/ruby.h。对我来说,关键是linecache19 v0.5.13这些步骤对我很有效。然而,要通过IDE(如Netbeans)实现这一点,您需要在之后执行
gem安装--忽略依赖项-v0.4.12ruby-debug-ide19
。这种方法在Windows7中也适用。如果您没有curl,您可以复制这些gem URL并将其粘贴到web浏览器中进行下载。然后在执行
gem install
之前将目录更改为下载路径。我不得不将
——使用ruby include=$SANDBOX/packages/ruby-1.9.3-p0
更改为
/include/ruby-1.9.1/ruby-1.9.3-p
,我刚刚从另一个讨论中读到ruby-debug19不再被积极维护。请参阅:建议使用新的调试器gem:group:deployment do gem'linecache19',0.5.13'gem'ruby-debug-base19x','>=0.11.30。pre10'gem'ruby-debug19',:require=>'ruby debug'end
% 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 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
...
# 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"