Break Point not working in Ruby 1.8.5?

This has something to do with the call_stack gem. Nevertheless, I find
ruby-debug far more productive. Give it a try.

http://www.datanoise.com/articles/2006/07/12/tutorial-on-ruby-debug

I've never tried it on Windows, but it works like a charm on a Mac. If you
do try it and it works on Win32, that would be good to know.

Mike-293 wrote:

I typically put the require statement at the top of the file under test, but
in any case, I cranked this whole thing up in Parallels on my Mac and
repro'ed your error. Here's how to fix it:

# top of file
require 'rubygems' # not sure this is necessary
require 'ruby-debug'
Debugger.start

Then someplace else in your program, put:

debugger

and you'll have a breakpoint. I'd be curious to understand why this is
necessary.

Steve

Al Evans-2 wrote:

I do must of my debugging using logs. On the rare occasion when I need to
examine something in a debugger, ruby-debug is far superior. Typically, what
I would be looking at with a debugger are code paths and data state changes,
neither of which breakpointer helps out with much.

--steve

Joshua Muheim-2 wrote:

Steve... I'm also on InstantRails/Windows and tried the suggestions in
this thread... Two things:

1. I had to add: require 'ruby-debug-base' to get this to work
2. my 'debugger' command doesn't make anything happen.

I tried it with and without the require 'rubygems' and that didn't
make any difference.

Any thoughts as to what I'm doing wrong?

Thanks...jon

Any errors or just a quiet failure?

Also are you doing:

ruby script\server webrick

to get your app running?

To be honest, I don't develop on Windows, so my test was on a hand-built
Ruby/MySQL/Rails install, not instant rails.

--steve

JESii wrote:

Quiet failure; I'm running Mongrel, but it's the same with webrick... I saw
that you're on Mac (nice setup; wish I were there :slight_smile:

Thanks, Steve.... your feedback is much appreciated...jon

Thank you. Out of curiosity, may I ask what the issue was that caused you to
break out the debugger? I've always been a fan of debuggers -- that is,
until I began Rails programming. The combination of tests and the logger has
been adequate for over 90% of my debugging needs.

--steve

Joshua Muheim-2 wrote:

Bharat... Thanks very much for getting back to me... here's what is
happening.

1. I followed the instructions you and Steve discussed. It failed for me,
but I got it to work by requiring 'ruby-debug-base' instead.
2. The require 'rubygems' is not necessary; I tried it both ways.
3. No browser hang - it just goes about its normal behavior and nothing in
the mongrel window.

I definitely agree with the assessment about InstantRails. I do have some
issues with it, but they are relatively minor at this point. I wish I could
say the same thing about RadRails which I do use, but which is completely
broken for updates. At least what I have seems to be holding together
moderately well.

Thanks again...jon

Bharat... "quiet failure" just means that nothing happened: no error
messages, no browser hang, no information in the server log.

BTW, I have read the Lenz book as well, along with two other books I am
working on: "Ruby for Rails" (David Black) and "Agile Web Development with
Rails" (Thomas & Hanssen) - both very good.

Re "formatted log viewing" - I don't know if this is what you mean, but I
use vim (Vi Improved - www.vim.org). They have several really nice plugins
for ruby/rails. If you're a vim person (I've used it for many years), then
you'll love this software, and it's free and very well supported.

Cheers...jon

I was having problems getting the right syntax to get the logger to work for
me (wanted to look at some session variables)... I finally figured out what
I was doing wrong and so now my logger stuff is working. At this point, I
figured I'd just try to get the debugger working for whenever I might need
it in the future. Actually not needed right this moment.

Cheers...jon

yeah, cygwin would have been my recommendation. Really, all you are looking
for is something with tail capabilities that understands terminal escape
sequences. I prefer to keep environments similar, where possible, so cygwin
makes sense. That way, whether I'm on Windows or *nix, ls works, tail works,
and so on.

Many Windows editors sense external modifications to files, but seldom do
they put you at the end of the file automagically. Alternatively, just write
a simple "tail" utility in C or Ruby (not very DRY :).

--steve

Joshua Muheim-2 wrote:

FYI... I've got MKS toolkit, which is very nice; having used that for quite
some time, it's a little hard to switch over to cygwin: I keep getting
bitten by cygwin's c-drive references.

...jon

Bharat Ruparel wrote:

I am glad that you brought up logs. Do you know an effective way of viewing "formatted" log in Windows environment? In linux, the less command does a great job of showing formatted entries. I have not been able to replicate it in the Windows environment. I do not want to use Cygwin since I have a dual boot machine and I can boot into Linux if I want to.

Well, it's no substitute for a good command-line shell, but RadRails has a "tail" function for log files. Just right-click on the log file in the file navigator and choose "Tail". Also, if you run mongrel (or webrick) from within RadRails, it puts the mongrel output to a console. So, stdout (puts) goes to the mongrel output and rails logging (logger) goes to the console tailing the development.log.

b

Sorry, apparently I've missed this thread. The installation procedure
of ruby-debug on Windows should be the same as on any other platform.
The only difference is that you have to select mswin32 version of
ruby-debug-base:

C:\>gem in ruby-debug
Bulk updating Gem source index for: http://gems.rubyforge.org
Select which gem to install for your platform (i386-mswin32)
1. ruby-debug 0.8.1 (ruby)
2. ruby-debug 0.8 (ruby)
3. ruby-debug 0.7.5 (mswin32)
4. ruby-debug 0.7.5 (ruby)
5. Skip this gem
6. Cancel installation

1

Install required dependency ruby-debug-base? [Yn] y
Select which gem to install for your platform (i386-mswin32)
1. ruby-debug-base 0.8.1 (mswin32)
2. ruby-debug-base 0.8.1 (ruby)
3. Skip this gem
4. Cancel installation

1

Successfully installed ruby-debug-0.8.1
Successfully installed ruby-debug-base-0.8.1-mswin32
Installing ri documentation for ruby-debug-0.8.1...
Installing ri documentation for ruby-debug-base-0.8.1-mswin32...
Installing RDoc documentation for ruby-debug-0.8.1...
Installing RDoc documentation for ruby-debug-base-0.8.1-mswin32...

The easiest way of debugging your Rails application is to run it with
rdebug script:

C:\rails-app>rdebug ./script/server

It should work with webrick or mongrel. If you use rdebug script you
don't have to require ruby-debug in your environment.rb file and to
start the debugger with Debugger.start method. Of course, you still
have to set your breakpoints either explicitly using debugger's
'break' command or via Kernel#debugger method.

Kent.

Thanks, Kent... using redbug as you suggested did the trick.

I am curious as to why the other approach didn't work... any thoughts on
that?

Cheers...jon

Bharat... There is a ruby/rails plugin for vim that does it for me, as I
recall. I tried getting to the vim.org site, and it seems to be having
problems. The plugin that I use is by Tim Pope, and you can reach him at
"tim - AT - pope.info" He was very helpful when I was setting it up. It's
a VERY extensive plugin, and worked right out of the box for me.

Here's a dump of my log; it doesn't show the coloring and highlighting that
my gvim gives me, so it's much nicer than it looks here. (E.g., the
"DEPRECATION WARNING" is highlighted in red...)

Cheers...jon

Processing AssetController#index (for 10.0.0.152 at 2007-03-25 12:18:26)
[GET]
  Session ID: 4cfdd7473a144e83709d3cd9463289f3
  Parameters: {"action"=>"index", "controller"=>"asset"}
Redirected to http://edp18:3010/asset/list
Completed in 0.00010 (10000 reqs/sec) | DB: 0.00000 (0%) | 302 Found
[http://edp18/asset]
DEPRECATION WARNING: model is deprecated and will be removed from Rails 2.0
See http://www.rubyonrails.org/deprecation for details. (called from
C:/Dev/INSTAN~1/rails_apps/AssetList/config/../app/controllers/application.r
b:11)
DEPRECATION WARNING: depend_on is deprecated and will be removed from Rails
2.0 See http://www.rubyonrails.org/deprecation for details. (called from
model_without_deprecation at
C:/Dev/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_con
troller/deprecated_dependencies.rb:13)
  User Columns (0.015000) SHOW FIELDS FROM users

Processing AssetController#list (for 10.0.0.152 at 2007-03-25 12:18:27)
[GET]
  Session ID: 4cfdd7473a144e83709d3cd9463289f3
  Parameters: {"action"=>"list", "controller"=>"asset"}
  Asset Columns (0.000000) SHOW FIELDS FROM assets
Rendering layoutfalsetemplateajax_scaffold/list.rhtml within layouts/asset
Rendering ajax_scaffold/list.rhtml
Start rendering component ({:action=>"table", :params=>{"action"=>"list",
"controller"=>"asset"}, :controller=>"/asset"}):