Ruby-debug不起作用。

4

我无法在调试模式下启动服务器:

尽管我已经安装了所有正确的gems,但服务器拒绝启动。

$ gem install ruby-debug
ERROR:  Error installing ruby-debug:
       rbx-require-relative requires Ruby version ~> 1.8.7.

这个方法不起作用,其他文章建议使用ruby-debug19:

David@DAVID-PC /c/triton6 
$ gem install ruby-debug19
Successfully installed ruby-debug19-0.11.6
1 gem installed
Installing ri documentation for ruby-debug19-0.11.6...
Installing RDoc documentation for ruby-debug19-0.11.6...

David@DAVID-PC /c/triton6 
$ rails server --debug
=> Booting WEBrick
=> Rails 3.1.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install > ruby-debug' 
Exiting

你有任何想法吗?

这是我的Gemfile:

source 'http://rubygems.org'

gem 'rails', '3.1.3'

# Bundle edge Rails instead:
# gem 'rails',     :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'
gem 'ruby-debug19'
gem 'execjs'
gem 'ruby-debug-ide'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails',   '~> 3.1.5'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# Use unicorn as the web server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

group :test do
# Pretty printed test output
gem 'turn', '0.8.2', :require => false
end

这段代码已经有一个新的分支并且正在运行。现在请使用 gem 'debugger'。以下是新版本被用于核心 Rails 项目的链接:https://github.com/matschaffer/knife-solo/pull/38 - Kevin Bedell
6个回答

4
确保您的Gemfile中有gem“ruby-debug19”,:require => 'ruby-debug',然后运行bundle install :)

编辑:添加了重要的:require =>语句,我之前忘记了。


我添加了我的Gemfile并仔细检查了我是否在正确的位置执行。 - David
有什么想法可以带我走出困境吗?我完全不知所措。 - David
我认为Joel的回答是正确的:gem "ruby-debug19",:require => "ruby-debug"。至少,这就是我的基于Ruby 1.9的Rails应用程序所说的(现在我烦了,实际上看了一些Gem文件...)。 - RyanWilcox

3

我在Aptana Studio 3中遇到了相同的问题(还有其他问题)以使得Ruby调试工作。我的设置和过程如下:

  • Mac OS X Lion 10.7.2
  • Aptana Studio 3 (Build 3.0.8.201201201658)
  • Using rvm, in my project working directory I have a .rvmrc stating:

    rvm use ruby-1.9.3-p0@mygemset
    
为了在Aptana Studio中实现Ruby调试,我现在有以下设置。
  • At the end of my Gemfile I have:

    gem "ruby-debug-base19x", "0.11.30.pre10"
    gem 'ruby-debug-ide'
    
请注意,我没有使用ruby-debug-ide19和ruby-debug19,Aptana Studio 拒绝使用这个gem。不管怎样,它总是选择ruby-debug-ide 0.4.16。
我也不使用ruby-debug-base19,而是使用ruby-debug-base19x。
  • To build the latest ruby-debug-base19x, be sure the specify the correct ruby context (include):

    rvm 1.9.3-p0@mygemset do gem install --pre ruby-debug-base19x -- --with-ruby-include=/Users/Freddy/.rvm/src/ruby-1.9.3-p0
    
失去rvm...当不使用rvm时该怎么办。
  • Don't forget to do Bundle install (or bundle update) from your project working directory. In my terminal, when I type'Bundle list', for the mentioned gems the following versions are listed:

    linecache19 (0.5.13)
    ruby-debug-base19x (0.11.30.pre10)
    ruby-debug-ide (0.4.16)
    
  • Important : if you have linecache19 version 0.5.12 instead of .13, download the latest version from RubyForge: ruby-debug19: Project Filelist. I Downloaded it to my ~/Downloads folder, so building and installing this gem in my rvm context is as follows:

    rvm 1.9.3-p0@mygemset do gem install ~/Downloads/linecache19-0.5.13.gem -- --with-ruby-include=/Users/Freddy/.rvm/src/ruby-1.9.3-p0
    
如果您需要安装linecache19版本0.5.13,请不要忘记再次运行“bundle update”。
在ide中运行调试器时,我遇到的最终问题(以及它的解决方案)在这里描述:Aptana 3 ruby debugger - Exception in DebugThread loop: undefined method `is_binary_data?'
将提供的代码放在xml_printer.rb中“module Debugger”语句上面即可。
享受吧!
-- Freddy
关于构建ruby-1.9.3-p0的说明。虽然超出了问题的范围,但由于构建也很麻烦,因此在这里提供一个提示。编译ruby-1.9.3.-p0时出现了多个与openssl相关的编译器错误。最好的方法是在rvm环境中安装openssl-0.9.8n软件包。
  • When you have XCode 4.2 installed, first you need to put the following in your .rvmrc or .profile :

    export CC=/usr/bin/gcc-4.2
    

不要忘记启用它,例如 $ source ~/.rvmrc


1

我已经安装了cldwalker/debugger gem并将其包含在我的gemfile中。当我运行Aptana 3调试服务器时,它仍然显示:无法找到'rdebug-ide'二进制脚本。可能需要安装'ruby-debug-ide' gem,或者可能需要将您的gem可执行目录添加到您的PATH中(通过'gem environment'检查位置)。 - Pierre Pretorius
你需要使用 'ruby-debug-ide' 吗?我个人不使用调试器的那一部分,也没有在我的 Gemfile 中安装这个 gem。你尝试过将它移除并查看是否可以正常使用调试器吗?我只在我的 gem 文件中添加了 'debugger',就可以通过 Rails 服务器进行调试了。 - Kevin Bedell

1
我想你的Gemfile中已经有了答案。
gem 'ruby-debug19', :require => 'ruby-debug'

堆栈跟踪显示了什么? - Joel Meador

0

让它对我起作用的原因是:

sudo gem install ruby-debug19
gem install linecache19
gem install ruby-debug-base19
bundle update
rails server -u

在发布复制粘贴的样板/逐字答案到多个问题时请小心,社区往往会将其标记为“垃圾信息”。如果您正在这样做,那通常意味着这些问题是重复的,因此请标记它们:http://stackoverflow.com/questions/7802124 - Kev
谢谢你的建议,我只是想要帮忙,因为我真的卡在那里了。 - standup75

0
这是我的解决方案。我按照这篇文章的步骤,但没有成功。:(
我在Gemfile中添加了下面的gem,并运行了$bundle install,然后就可以了。
在Gemfile中添加如下内容: gem 'ruby-debug-ide', '~> 0.4.22'
Installing ruby-debug-ide 0.4.22
Using sass 3.2.19
Using sass-rails 4.0.3
Using sdoc 0.4.0
Using spring 1.1.3
Using sqlite3 1.3.9
Using turbolinks 2.2.2
Using uglifier 2.5.1
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
-SVE1411EGXB:~/Desktop/myapp$ 

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接