使用 Ruby 1.9.3 进行 ruby​​ 调试?

发布于 2024-12-14 16:53:34 字数 653 浏览 0 评论 0原文

我刚刚更新到 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

在我的 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"

可以使用最新版本的 Ruby 运行调试吗?

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.

% 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

# 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

纵情客 2024-12-21 16:53:56

如果你没有rvm并且假设你的ruby安装在/usr/local/ruby-1.9.3-po中,你可以使用这个命令:

curl -L https://raw.github.com/gist/1533750 |须藤 /bin/bash

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:

curl -L https://raw.github.com/gist/1533750 | sudo /bin/bash

临走之时 2024-12-21 16:53:52

您还需要检查 gem 'ruby_source_code' 是否已安装。

检查:http://bugs.ruby-lang.org/issues/1857#note -8

Also you need to check if the gem 'ruby_source_code' is already installed.

Check: http://bugs.ruby-lang.org/issues/1857#note-8

喜你已久 2024-12-21 16:53:51

在这里查看我的答案:
Ruby-debug 无法工作 - Stack Overflow

它是关于让 Ruby 调试与以下设置

  • Mac OS X Lion 10.7.2
  • 配合使用Aptana Studio 3 (Build 3.0.8.201201201658)
  • 使用rvm,在我的项目工作目录中我有一个.rvmrc说明:

    rvm 使用 ruby​​-1.9.3-p0@mygemset
    

基本上,我必须使用:

linecache19 (0.5.13)
ruby-debug-base19x (0.11.30.pre10)
ruby-debug-ide (0.4.16)

请注意,我没有使用 ruby​​-debug-base19,而是使用 ruby​​-debug-base19x

我希望这有帮助!

——弗雷迪

See my answer here :
Ruby-debug not working - Stack Overflow

It's about getting Ruby debugging to work with the following setup

  • 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
    

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

I hope this helps!

-- Freddy

泪之魂 2024-12-21 16:53:49

顺便说一句,如果您使用 ruby​​1.9.3 的最新补丁(falcon,https://gist.github.com/1688857< /a>),使用以下命令

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

BTW, if you use the newest patch for ruby1.9.3 (falcon, https://gist.github.com/1688857), use following commands

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
绝不服输 2024-12-21 16:53:48

对于 Windows 用户:

首先下载:linecache19-0.5.13.gem 和 ruby​​-debug-base19-0.11.26.gem
来自: http://rubyforge.org/frs/?group_id=8883&release_id= 46303

假设:Ruby在c:\Ruby1.93

把下载的gem文件放到c:\temp
(linecache19-0.5.13.gem 和 ruby​​-debug-base19-0.11.26.gem)

然后从命令行执行:

gem 安装 c:\temp\linecache19-0.5.13.gem

gem 安装 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

For Windows Users:

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

Assumption: Ruby is in c:\Ruby1.93

put the gem files downloaded to c:\temp
(linecache19-0.5.13.gem and 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

書生途 2024-12-21 16:53:46

也许不是这个问题的明确答案,但我是被一系列封闭的重复项引导到这里的。

对我来说,问题是我在 ruby​​ 1.8 和 ruby​​ 1.9 中运行一个项目,而我的 Gemfile 需要进行此更改:

gem 'debugger', :require => 'ruby-debug', :platforms => :mri_19
gem 'ruby-debug', :platforms => :mri_18

现在它适用于这两种 ruby​​。

有关更多信息,请参见此处:http://gembundler.com/man/gemfile。 5.html#PLATFORMS-平台-

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:

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-

不寐倦长更 2024-12-21 16:53:44

其他人在评论中发帖尝试 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'

安装后我立即注意到我的 .irbrc 没有加载,所以我没有得到漂亮的控制台输出。我还将这个添加到我的 '~/.pryrc'

# setting up pry to have irb helpers like reload!
if defined?(Rails) && Rails.env
  extend Rails::ConsoleMethods
end

Pry 有一些我想要检查的好功能,一旦有一种简单的方法将其集成到 Ruby 1.9 的 Rails 项目中,我可能还会返回 ruby​​-debug .3.我可以从其他答案中运行curl命令,但这是我必须向我的队友指出我们的Rails项目的东西,所以在我看来它不能很好地扩展。

Someone else posted in a comment to try Pry, which is what I did. This is what's necessary for 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 .irbrc doesn't load, so I don't get pretty console output. I also added this to my '~/.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.

我是有多爱你 2024-12-21 16:53:43

linecache19 和 ruby​​-debug-base19 的安装可以轻松完成:

bash < <(curl -L https://raw.github.com/gist/1333785)

Installation of linecache19 and ruby-debug-base19 can be easily done with:

bash < <(curl -L https://raw.github.com/gist/1333785)
清君侧 2024-12-21 16:53:41

更新(2012 年 4 月 28 日)

尝试使用新的 debugger gem 作为 ruby​​-debug 的替代品。

感谢@ryanb


更新(2012 年 3 月 2 日)

linecache19 和 ruby​​-debug-base19 的安装可以轻松完成:

bash < <(curl -L https://raw.github.com/gist/1333785)

(归功于@fredostarr)


原始答案

您看过ruby-debug19 上ruby-1.9.3-preview1

这是一个临时解决方案:
http://blog.wyeworks。 com/2011/11/1/ruby-1-9-3-and-ruby-debug

摘自网站:

首先下载linecache19-0.5.13.gem并
ruby-debug-base19-0.11.26.gem 来自
http://rubyforge.org/frs/?group_id=8883,然后...

$ gem install linecache19-0.5.13.gem 
构建本机扩展。这可能需要一段时间...
成功安装linecache19-0.5.13
安装了 1 个宝石
$ gem install ruby​​-debug-base19-0.11.26.gem -- --with-ruby-include=/Users/santiago/.rbenv/source/ruby-1.9.3-p0  
构建本机扩展。这可能需要一段时间...
成功安装 ruby​​-debug-base19-0.11.26
安装了 1 个宝石
$ IRB
irb(主):001:0>需要“ruby-debug”
=>真的

Update (April 28, 2012)

Try the new debugger gem as a replacement for ruby-debug.

(credit to @ryanb)


Update (March 2, 2012)

Installation of linecache19 and ruby-debug-base19 can be easily done with:

bash < <(curl -L https://raw.github.com/gist/1333785)

(credit to @fredostarr)


Original answer

Have you looked at ruby-debug19 on ruby-1.9.3-preview1?

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文