Comments (5)
Sure, it is possible. You can debug any Rack application, including Sinatra and Rails.
For now, AFAIK there is no way to use Passenger for debugging Rack applications. I use Webrat or Mongrel instead, by the following algorithm:
-
Open Vim (or gVim/MacVim) in the root dir of the app
-
Run debugger by:
:Rdebugger (for Rails 2.*) :Rdebugger 'script/rails start' (for Rails 3.*) :Rdebugger '/usr/bin/rackup config.ru' (for any other Rack app, e.g. Sinatra or just plain Rack app).
Note that you have to use the full absolute path to rackup, usually it is /usr/bin. Also, specify the path to config.ru as the relative path from the app's root dir. I.e. if config.ru is placed right in the root path of the app, you can specify it just as 'config.ru'
This command will start rdebug-ide, which will start app server like Webrat and Mongrel on some port (see below).
3. Put breakpoint e.g. somewhere in your controller.
4. Open a route for that controller in some browser, e.g. http://localhost:3000/posts
Rails usually starts itself on the 3000 port, 'rackup' usually starts Rack apps on the 9292 port.
5. After that, debugger should stop execution on the breakpoint you specified and you should be able to see variables there.
Ports 39767 and 39768 are inner ports used only by vim-ruby-debugger for passing messages from and to rdebug-ide, and you don't need to use them at all.
Please keep me posted if you can or can't run it successfully. I'm sure we'll be able to make it work in any case.
Thanks for using it. :)
from vim-ruby-debugger.
Thank you for the quick and detailed reply.
I had to install the pre-release version of mongrel since I'm using the current version of ruby (1.9.2) as per: http://stackoverflow.com/questions/1073841/gem-install-mongrel-fails-with-ruby-1-9-1/2892360#2892360
I also installed and tried Thin.
I can run the following commands from the terminal and in root of my Sinatra app and they all launch the server and allow me to navigate to http://localhost:9292 to view the app:
$ rackup
127.0.0.1 - - [09/Jan/2011 15:48:10] "GET / HTTP/1.1" 200 4 0.0164
127.0.0.1 - - [09/Jan/2011 15:48:10] "GET /favicon.ico HTTP/1.1" 200 28 0.0009
- or -
$ rackup -s thin
>> Thin web server (v1.2.7 codename No Hup)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:9292, CTRL+C to stop
127.0.0.1 - - [09/Jan/2011 15:51:41] "GET / HTTP/1.1" 200 4 0.0319
127.0.0.1 - - [09/Jan/2011 15:51:41] "GET /favicon.ico HTTP/1.1" 200 28 0.0011
- or -
$ rackup -s webrick
[2011-01-09 15:52:16] INFO WEBrick 1.3.1
[2011-01-09 15:52:16] INFO ruby 1.9.2 (2010-12-25) [i686-linux]
[2011-01-09 15:52:16] INFO WEBrick::HTTPServer#start: pid=5442 port=9292
127.0.0.1 - - [09/Jan/2011 15:52:22] "GET / HTTP/1.1" 200 4 0.0031
127.0.0.1 - - [09/Jan/2011 15:52:22] "GET /favicon.ico HTTP/1.1" 200 28 0.0008
- or explicitly (mongrel seems to be default with just 'rackup') -
$ rackup -s mongrel
127.0.0.1 - - [09/Jan/2011 15:53:48] "GET / HTTP/1.1" 200 4 0.0146
127.0.0.1 - - [09/Jan/2011 15:53:48] "GET /favicon.ico HTTP/1.1" 200 28 0.0009
However, when in vim I do:
:Rdebugger '/usr/local/bin/rackup config.ru'
or :Rdebugger '/usr/local/bin/rackup -s mongrel config.ru'
or :Rdebugger '/usr/local/bin/rackup -s thin config.ru'
etc.
Rdebugger reports that the debugger has been started, but I get nothing in the browser at http://localhost:9292
from vim-ruby-debugger.
Looks like you use Ruby 1.9.2 as default Ruby installed system-wide, and without RVM, right?
Please do these things:
- Update vim-ruby-debugger to the latest version
- Add 'let g:ruby_debugger_debug_mode = 1' to your .vimrc
- Go to the Sinatra app's dir and run Vim
- Execute :Rdebugger /usr/local/bin/rackup
- Send me log files:
~/.vim/tmp/ruby_debugger
~/.vim/tmp/ruby_debugger_log
~/.vim/tmp/ruby_debugger_output
Thanks!
from vim-ruby-debugger.
Pulling your latest changes from today fixed the problem!
Before pulling latest. This was in ruby_debugger_output:
Fast Debugger (ruby-debug-ide 0.4.16, ruby-debug-base 0.11) listens on 127.0.0.1:39767
/usr/local/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.16/lib/ruby-debug-ide.rb:112:in debug_load' /usr/local/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.16/lib/ruby-debug-ide.rb:112:in
debug_program'
/usr/local/lib/ruby/gems/1.9.1/gems/ruby-debug-ide-0.4.16/bin/rdebug-ide:87:in <top (required)>' /usr/local/bin/rdebug-ide:19:in
load'
/usr/local/bin/rdebug-ide:19:in `
Uncaught exception: no such file to load -- /home/nick/workspace/test_project//usr/local/bin/rackup
As a sanity check I ran:
Rdebugger '../../../../usr/local/bin/rackup'
This worked! Again, this is prior to pulling latest.
Then I pulled your latest changes and it now works with the absolute path as well:
Rdebugger '/usr/local/bin/rackup'
It appears that somewhere in b49005f you fixed the problem.
And yes, you're exactly right. 1.9.2 and no RVM
Everything is working perfectly now (breaks, variable browser). Thank you!
from vim-ruby-debugger.
Great! Yes, I've fixed path resolving, and now you can use just ':Rdebugger rackup' if /usr/local/bin is presented in your PATH environment variable.
from vim-ruby-debugger.
Related Issues (20)
- Screenshot is broken HOT 4
- Rdebugger calls vim instead of mvim and fails --servername HOT 5
- Debugger is not running HOT 22
- RdbStop not working HOT 10
- Caught deadly signal ABRT HOT 2
- Debuger not start HOT 2
- Not hit breakpoint on Linux HOT 50
- debugger errors at every command HOT 5
- Debugger terminates HOT 10
- "VIM not found" debugger wont start server HOT 8
- Can't debug because 'builder' gem is loaded HOT 7
- `:Rdebugger` does not return HOT 1
- Windows support HOT 2
- Customize window positions (variables, breakpoints, etc..)
- Weird error HOT 2
- Is it working under ruby 2.0.0? HOT 6
- Не запускается debugger HOT 4
- Могу ли я использовать дебаггер, когда я запускаю задачи через tpope/vim-rake ? HOT 1
- Don't running RdbTest HOT 2
- Unable to run a simple rb file and getting an error trying to run debugger
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim-ruby-debugger.