ruby-on-rails – 如何在ruby中安装ruby-debug 1.9.3 / Rails 3.2.1

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 如何在ruby中安装ruby-debug 1.9.3 / Rails 3.2.1前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Possible Duplicate:
07000

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

>我使用的是Ruby 1.9.3-p0
>我使用的是Rails 3.2(当然是Gemfile)
>我没有使用RVM – 相反,我有一个完全沙箱的目录,其中包含所有可执行文件,宝石,来源等.我把它称为$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-debug不起作用

如果我尝试从命令行构建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

我失踪了什么?

–with-ruby-include是否预期会有所不同?目前的ruby-debug19破了吗?

解决方法

感谢@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 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"

希望这将帮助别人.

猜你在找的Ruby相关文章