使用 Ruby 1.9.3 进行 ruby 调试?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8087610/
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
ruby-debug with Ruby 1.9.3?
提问by dkobozev
I just updated to Ruby 1.9.3p0 and Rails 3.1.1. Now when I try to launch the server, it complains that I should install ruby-debug, even though it's already installed.
我刚刚更新到 Ruby 1.9.3p0 和 Rails 3.1.1。现在,当我尝试启动服务器时,它抱怨我应该安装ruby-debug,即使它已经安装。
% rails server --environment=development --debug
=> Booting WEBrick
=> Rails 3.1.0 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
In my Gemfile I have
在我的 Gemfile 中,我有
# see: http://stackoverflow.com/questions/1083451/debugging-in-ruby-1-9
gem 'ruby-debug-base19', "0.11.24"
gem 'ruby-debug19', "0.11.6"
Is it possible to run debug with the latest version of Ruby?
是否可以使用最新版本的 Ruby 运行调试?
回答by Dty
Update (April 28, 2012)
更新(2012 年 4 月 28 日)
Try the new debuggergem as a replacement for ruby-debug.
尝试使用新的调试器gem 作为 ruby-debug 的替代品。
Update (March 2, 2012)
更新(2012 年 3 月 2 日)
Installation of linecache19 and ruby-debug-base19 can be easily done with:
linecache19 和 ruby-debug-base19 的安装可以通过以下方式轻松完成:
bash < <(curl -L https://raw.github.com/gist/1333785)
Original answer
原答案
Have you looked at ruby-debug19 on ruby-1.9.3-preview1?
你在 ruby-1.9.3-preview1 上看过ruby-debug19吗?
Here's a temporary solution: http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug
Excerpt from the site:
First download linecache19-0.5.13.gem and ruby-debug-base19-0.11.26.gem from http://rubyforge.org/frs/?group_id=8883, then …
$ 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=/Users/santiago/.rbenv/source/ruby-1.9.3-p0 Building native extensions. This could take a while... Successfully installed ruby-debug-base19-0.11.26 1 gem installed $ irb irb(main):001:0> require 'ruby-debug' => true
这是一个临时解决方案:http: //blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug
网站摘录:
首先从http://rubyforge.org/frs/?group_id=8883下载 linecache19-0.5.13.gem 和 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=/Users/santiago/.rbenv/source/ruby-1.9.3-p0 Building native extensions. This could take a while... Successfully installed ruby-debug-base19-0.11.26 1 gem installed $ irb irb(main):001:0> require 'ruby-debug' => true
回答by fredostarr
Installation of linecache19 and ruby-debug-base19 can be easily done with:
linecache19 和 ruby-debug-base19 的安装可以通过以下方式轻松完成:
bash < <(curl -L https://raw.github.com/gist/1333785)
回答by Eric Hu
Someone else posted in a comment to try Pry, which is what I did. This is what's necessary for Rails:
其他人在评论中发布尝试 Pry,这就是我所做的。这是 Rails 所必需的:
# Gemfile
gem 'pry-rails'
# In your Rails Project where you want a 'debugger'
puts 'i want to insert some code between this'
binding.pry
puts 'and this'
Immediately after installing I notice my .irbrcdoesn't load, so I don't get pretty console output. I also added this to my '~/.pryrc'
安装后我立即注意到我.irbrc没有加载,所以我没有得到漂亮的控制台输出。我还将它添加到我的“~/.pryrc”中
# setting up pry to have irb helpers like reload!
if defined?(Rails) && Rails.env
extend Rails::ConsoleMethods
end
Pry has some nice features that I've wanted to check out, and I may yet return to ruby-debug once there's a simple way to integrate it into a Rails project for Ruby 1.9.3. I can run the curl command from the other answers, but this is something I'll have to point my teammates to for our Rails project, so it doesn't scale well IMO.
Pry 有一些我想查看的不错的特性,一旦有一种简单的方法将它集成到 Ruby 1.9.3 的 Rails 项目中,我可能还会回到 ruby-debug。我可以从其他答案中运行 curl 命令,但这是我必须为我们的 Rails 项目指出我的队友的东西,所以它不能很好地扩展 IMO。
回答by user132837
Maybe not the definitive answer to this question, but I was lead here by a chain of closed duplicates.
也许不是这个问题的明确答案,但我被一连串封闭的副本引导到这里。
For me the problem was that I run a project in both ruby 1.8 and ruby 1.9, and my Gemfile needed this change:
对我来说,问题是我在 ruby 1.8 和 ruby 1.9 中运行了一个项目,而我的 Gemfile 需要这个更改:
gem 'debugger', :require => 'ruby-debug', :platforms => :mri_19
gem 'ruby-debug', :platforms => :mri_18
Now it works for both rubies.
现在它适用于两种红宝石。
For more info see here: http://gembundler.com/man/gemfile.5.html#PLATFORMS-platforms-
有关更多信息,请参见此处:http: //gembundler.com/man/gemfile.5.html#PLATFORMS-platforms-
回答by Rommel
For Windows Users:
对于 Windows 用户:
First Download :linecache19-0.5.13.gem and ruby-debug-base19-0.11.26.gem From : http://rubyforge.org/frs/?group_id=8883&release_id=46303
第一次下载:linecache19-0.5.13.gem 和 ruby-debug-base19-0.11.26.gem 来自:http://rubyforge.org/frs/?group_id=8883&release_id=46303
Assumption: Ruby is in c:\Ruby1.93
假设:Ruby 在 c:\Ruby1.93
put the gem files downloaded to c:\temp (linecache19-0.5.13.gem and ruby-debug-base19-0.11.26.gem)
将下载的 gem 文件放到 c:\temp(linecache19-0.5.13.gem 和 ruby-debug-base19-0.11.26.gem)
then execute from command line:
然后从命令行执行:
gem install c:\temp\linecache19-0.5.13.gem
gem install c:\temp\ruby-debug-base19-0.11.26.gem -- --with-ruby-include=C:\Ruby1.93\include\ruby-1.9.1\ruby-1.9.3-p0
gem install c:\temp\linecache19-0.5.13.gem
gem install c:\temp\ruby-debug-base19-0.11.26.gem -- --with-ruby-include=C:\Ruby1.93\include\ruby-1.9.1\ruby-1.9.3-p0
回答by mindreframer
BTW, if you use the newest patch for ruby1.9.3 (falcon, https://gist.github.com/1688857), use following commands
顺便说一句,如果您使用 ruby1.9.3 的最新补丁(falcon,https://gist.github.com/1688857 ),请使用以下命令
wget http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
wget http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
gem install linecache19-0.5.13.gem
## with rvm:
gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=$HOME/.rvm/src/ruby-1.9.3-p0-falcon
## with rbenv (this is a guess):
gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=$HOME/.rbenv/source/ruby-1.9.3-p0-falcon
回答by Visionscaper
See my answer here : Ruby-debug not working - Stack Overflow
在此处查看我的答案: Ruby-debug not working - 爱编程的大狗
It's about getting Ruby debugging to work with the following setup
这是关于让 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
- Mac OS X Lion 10.7.2
- Aptana Studio 3(内部版本 3.0.8.201201201658)
使用 rvm,在我的项目工作目录中,我有一个 .rvmrc 说明:
rvm use ruby-1.9.3-p0@mygemset
Basically, I had to use :
基本上,我不得不使用:
linecache19 (0.5.13)
ruby-debug-base19x (0.11.30.pre10)
ruby-debug-ide (0.4.16)
Note that I'm not using ruby-debug-base19 but ruby-debug-base19x
请注意,我使用的不是 ruby-debug-base19 而是 ruby-debug-base19x
I hope this helps!
我希望这有帮助!
-- Freddy
——弗雷迪
回答by feroult
Also you need to check if the gem 'ruby_source_code' is already installed.
您还需要检查 gem 'ruby_source_code' 是否已经安装。
回答by Alain Beauvois
If you don't have rvm and assuming you ruby installation is in /usr/local/ruby-1.9.3-po your can use this command:
如果您没有 rvm 并假设您的 ruby 安装在 /usr/local/ruby-1.9.3-po 中,您可以使用以下命令:
curl -L https://raw.github.com/gist/1533750| sudo /bin/bash
curl -L https://raw.github.com/gist/1533750| 须藤/bin/bash

