6 Replies Last post: Feb 29, 2012 7:05 PM by Stefan Lindbohm  
Tomasz Korzeniowski Newbie 1 posts since
Nov 3, 2009
Currently Being Moderated

Nov 3, 2009 4:11 PM

How can I use RubyMine debugger in Sinatra app

I have simple Sinatra app in the simple.rb file

 

require 'rubygems'

require 'sinatra'


get '/' do

  "Simple service"

end

 

I start application within RubyMine with use of shotgun script

 

/usr/bin/ruby -e STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift) /usr/bin/rdebug-ide --port 58272 -- /Users/korzonek/.gem/ruby/1.8/bin/shotgun simple.rb

Fast Debugger (ruby-debug-ide 0.4.5) listens on :58272

== Shotgun starting Rack::Handler::Mongrel on localhost:9393

::1 - - [03/Nov/2009 14:04:16] "GET / HTTP/1.1" 200 3 0.0158

 

Unfortunately breakpoints and all debugger goodies don't work

 

Has anybody built Sinatra application with help of RubyMine?

Roman.Chernyatchik  JetBrains 1,452 posts since
Sep 18, 2007
Currently Being Moderated
Nov 4, 2009 1:19 PM in response to: Tomasz Korzeniowski
Re: How can I use RubyMine debugger in Sinatra app

Hi,

 

Just tried your example and all works in my case:

Screen shot 2009-11-04 at 13.13.01.png

I've just launch script in debug mode and opened "http://localhost:4567/" url in my browser. I'm using MacOS 10.6.1, Safari, ruby 1.8.6, mongrel, gems: ruby-debug-base (0.10.3), ruby-debug-ide (0.4.9), sinatra (0.9.4)

Probably you tried to open application on debugger port (54515 on screenshot) instead of web server port (4567). Here 54515 port is for internal communication between debugger and RubyMine and you shouldn't use it.
Nikita Vasilyev Newbie 8 posts since
Oct 17, 2009
Currently Being Moderated
Feb 3, 2010 8:42 AM in response to: Tomasz Korzeniowski
Re: How can I use RubyMine debugger in Sinatra app

I've tried to debug Rack app with no luck. Sinatra rides on Rack, so it should be the same.

 

I can run it

 

rack-run.png

 

But I can't debug it

 

rack-debug.png

I suppose the problem is the current sequence of arguments:

 

/usr/bin/ruby -e STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift) -- /usr/local/bin/shotgun /Users/nikitavasilev/.gem/ruby/1.8/bin/rdebug-ide --port 63289 -- /Users/nikitavasilev/Sites/heroku/jsonp/config.ru

 

Maybe this will work:

 

/usr/bin/ruby -e STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift) -- /Users/nikitavasilev/.gem/ruby/1.8/bin/rdebug-ide --port 63289 -- /usr/local/bin/shotgun /Users/nikitavasilev/Sites/heroku/jsonp/config.ru

 

but I don't even know how run it. I lost in configuration settings

 

rack-settings.png

Roman.Chernyatchik  JetBrains 1,452 posts since
Sep 18, 2007
Currently Being Moderated
Feb 3, 2010 4:47 PM in response to: Nikita Vasilyev
Re: How can I use RubyMine debugger in Sinatra app

 

 

/usr/bin/ruby -e STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift) -- /usr/local/bin/shotgun /Users/nikitavasilev/.gem/ruby/1.8/bin/rdebug-ide --port 63289 -- /Users/nikitavasilev/Sites/heroku/jsonp/config.ru

 

Maybe this will work:

 

/usr/bin/ruby -e STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift) -- /Users/nikitavasilev/.gem/ruby/1.8/bin/rdebug-ide --port 63289 -- /usr/local/bin/shotgun /Users/nikitavasilev/Sites/heroku/jsonp/config.ru

The second variant is more reasonable because you should pass all scripts and it's arguments to rdebug-ide script.

 

As far as I understand you need to launch "/usr/local/bin/shotgun" ruby script and pass "/Users/nikitavasilev/Sites/heroku/jsonp/config.ru" as a parameter? In such case your run configuration settings should be

1. Ruby Script: /usr/local/bin/shotgun

2. Script arguments: /Users/nikitavasilev/Sites/heroku/jsonp/config.ru

3. Ruby arguments: leave default settings: -e STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift)

Nikita Vasilyev Newbie 8 posts since
Oct 17, 2009
Currently Being Moderated
Feb 3, 2010 6:15 PM in response to: Roman.Chernyatchik
Re: How can I use RubyMine debugger in Sinatra app

I run RubyMine debugger. Your instructions was right, except script arguments part.

 

shotgun-2.png

I removed arguments and now it almost works (config.ru fetched from working directory). Well, by "almost works" I mean I can start debugger, but it doesn't stop on breakpoints.

 

shotgun.png

 

I'm a little bit confused. Why Rubymine can't run .ru files by default? Rack using them as configuration files.

Manish Khettry Newbie 9 posts since
Mar 25, 2010
Currently Being Moderated
Sep 24, 2011 4:08 AM in response to: Tomasz Korzeniowski
Re: How can I use RubyMine debugger in Sinatra app

I'm having similar issues. I can run my sinatra app but ruby mine doesn't stop at breakpoints.

 

Here is my run configuration:

 

Ruby Script: /Users/manish/.rvm/gems/ruby-1.8.7-p334@helios/bin/rerun

Script Argument: -- rackup --port 8081 /Users/manish/repos/backlot/helios/config.ru

Ruby Arguments [left unchanged]: -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)

 

Any help would be appreciated.

Stefan Lindbohm Newbie 1 posts since
Feb 29, 2012
Currently Being Moderated
Feb 29, 2012 7:28 PM in response to: Tomasz Korzeniowski
Re: How can I use RubyMine debugger in Sinatra app

I've had the same problem and think I found the cause. I'll share it even though this is an old thread now since I got here on a billion different searches on the matter.

 

The key is that rdebug-ide runs whatever it's passed as it is, and we're passing stuff that run in non-debug mode. For rackup and thin everything works by just adding the debug flag to the script arguments. Shotgun, however, doesn't seem to pass the debug flag correctly to app server instances it starts so that's still unresolved to me. Two options that work are:

 

Ruby script: /path/to/thin

Script arguments: start -D

Working directory: /path/to/project/

 

Ruby script: /path/to/rackup

Script arguments -d

Working directory: /path/to/project/

 

So the long and short is: get everything running in debug mode all the way down to your application.

More Like This

  • Retrieving data ...