我已完成打印到控制台 - 我希望升级到20世纪并开始使用调试器!但是如何安装ruby-debug?当我尝试安装ruby-debug19 gem时,ruby-debug.c
的本机编译失败。我查看过其他SO帖子但尚未找到答案...
如果我将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,使用指向当前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-包括期待不同的东西?当前的ruby-debug19是否已损坏?
答案 0 :(得分:19)
感谢@Marc Talbot在OP中的评论,我发现了一个工作方法。
% 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"
希望这会有所帮助。
答案 1 :(得分:2)
(从您的日志中,我假设您使用的是Linux,特别是Debian发行版) 有一个简单的解决方案: 在shell中,
sudo apt-get install ruby-dev1.9.3
注意:我实际上并不知道是否有名为ruby-dev1.9.3
的软件包,因为我为1.9.2安装了ruby-dev
,这是ruby-dev1.9
(我认为。那是一个如果有人知道它们是什么,请发表评论。
此软件包安装解释器所需的C扩展所需的标头(ruby.h
)。