How do I configure Aptana 3 to run my Rails server in debug mode so it stops on breakpoints?
Asked Answered
D

1

6

I'm using Aptana Studio 3 on Mac OS X. I'm trying to run my server in debug mode so I can set breakpoints and step through my code. I created the below debug configuration

onfigure

with the "server" argument ...

enter image description here

However, when I start my server in debug mode (by right clicking on my project, selecting Debug As -> Debug Configurations and clicking the "Debug" button on the resulting dialog after I've selected the above configuration), the server starts up, but when I invoke code (using a curl command) to invoke the method, the curl method hangs, seemingly at the breakpoint ...

enter image description here

In the Aptana Studio console I see the "entered create" output, but I don't see the "done building" line. But the Aptana IDE doesn't highlight the line where I set the breakpoint like I'd expect it to. Below is the Aptana console. What else do I need to do so that I can interact with the IDE properly in debug mode?

Fast Debugger (ruby-debug-ide 0.7.0, debase 0.2.4.1, file filtering is supported) listens on 127.0.0.1:50900
=> Booting Puma
=> Rails 5.2.2.1 application starting in development 
=> Run `rails server -h` for more startup options
[79989] Puma starting in cluster mode...
[79989] * Version 3.11.4 (ruby 2.5.1-p57), codename: Love Song
[79989] * Min threads: 5, max threads: 5
[79989] * Environment: development
[79989] * Process workers: 2
[79989] * Phased restart available
[79989] * Listening on tcp://0.0.0.0:3000
[79989] Use Ctrl-C to stop
[79989] - Worker 0 (pid: 80014) booted, phase: 0
[79989] - Worker 1 (pid: 80015) booted, phase: 0
Started POST "/users" for 127.0.0.1 at 2019-10-13 13:44:17 -0500
  [1m[35m (5.5ms)[0m  [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
Processing by UserController#create as JSON
  Parameters: {"first_name"=>"Dave", "last_name"=>"Smith", "email"=>"[email protected]"}
entered create
Dipterocarpaceous answered 13/10, 2019 at 18:49 Comment(2)
The approach which you have taken is correct and as far as i know the steps to set debug configuration is also proper , but can you update the debug gems to ruby-debug-base19 (0.11.25) ruby-debug-ide19 (0.4.12) ruby-debug19 (0.11.6) and verify once , Before that try once using rails s --debugger.Eduard
One Small question, Did you try to write a simple/normal ruby file and then right click on it and select Debug As > Ruby application , Does the IDE opens the debug perspective ?Eduard
E
0

The approach which you have taken is correct and as far as i know the steps to set debug configuration is also proper .

Approach 1 to Fix :

Use the rails s --debugger and check whether its working.

Approach 2 to Fix :

Try once by updating the to ruby-debug-base19 (0.11.25) ruby-debug-ide19 (0.4.12) ruby-debug19 (0.11.6) and verify once.

Approach 3 to Fix : Remote Debugging ::

As the netbeans & Aptana share the same debug core , we can do a remote debugging too , the thread mentioned here can help . Remote debugging Rails application in Aptana Studio 3 we can follow the steps in order to ensure remote debugging works.

Basically, run the ruby app using rdebug-ide -p 7000 (or whatever port you want), then inside the IDE, go to Run > Debug configurations. On the left hand side, select "Remote Ruby Debug Session" and then add a new configuration there (the plus icon above the list). Enter the proper host IP/name and port you entered on the command line.

How do we debug if we have a rake file and tasks to execute ? If we are using a rake file and tasks to execute , you can have the reference in the thread here How to debug ruby tests in Eclipse/Aptana Studio? 1. Run > Debug As > Debug configurations. Then add an entry under Ruby application. Point it at your rake script path (say /usr/local/bin/rake) as the file to launch. 2. The Arguements should be edited to pass in your app's Rakefile as the first arg and the rake task as the second arg. (i.e. /my/path/to/project/Rakefile build).

Note : Sometimes there might be a possibility of a specific gem causing a issue , if we remove a gem and then bundle it and try it might work out , try this if nothing works out.

Eduard answered 21/11, 2019 at 14:12 Comment(8)
Taking this step by step, I tried your approach 1. How do I set up the Aptana debugging configuration? I tried making my "Program Arguments "s --debugger" but when I click the "Debug" button (the button right below the "Apply" button in my first screen shot), I get the error, "cannot load such file -- rack/handler/--debugger".Dipterocarpaceous
The Approach 1 (rails server --debugger) which was mentioned was to try from the console/terminal , when we just execute the command in terminal ,we can see the below message as its starting in debugger mode => Booting WEBrick => Rails 3.0.0 application starting on 0.0.0.0:3000 => Debugger enabled . This is to ensure that it can work from outside , when it works outside the IDE , You can just enter --debugger in arguments and try the same.Eduard
That's fair. So running "rails s --debugger" on the command line gives the same error -- "/Users/davea/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:291:in `require': cannot load such file -- rack/handler/--debugger (LoadError)".Dipterocarpaceous
Thanks for the response dave , Do you have a environment.rb configured and if you have change the ENV["RAILS_ENV"] = "development" and then execute the below command "rails server -e development" is working , if it works then we will append --debugger with the command and checkEduard
we can also try with "gem install byebug" and then change the snippet to the below just to check whether the debug works through this channel , Snippet is as below . def create: print "Entered Create \n" byebug @book = buildbook(params) print "Done Building"Eduard
Hi @redhatviky, so ENV["RAILS_ENV"] was already set as development and running "rails server -e development" booted up the server normally. Running "rails server -e development --debugger" caused the same error that I had listed in my comment above. Are you sure "--debugger" is a valid directive with my version of RoR? I had asked once but they seem to doubt it -- #57796258Dipterocarpaceous
Gotcha , I was digging deep on it and followed the link youtrack.jetbrains.com/issue/RUBY-20684 , can you try the below command :: bundle exec /Users/some/.rbenv/versions/2.5.1/bin/ruby /Users/some/.gem/ruby/2.5.0/gems/ruby-debug-ide-0.7.0.beta6/bin/rdebug-ide --key-value --disable-int-handler --evaluation-timeout 10 --evaluation-control --time-limit 100 --memory-limit 0 --rubymine-protocol-extensions --port 61019 --host 0.0.0.0 --dispatcher-port 61020 -- /Users/some/Repo/mrcr/timecrypt/bin/rails server Puma -b 0.0.0.0 -p 3000 -e developmentEduard
So I replaced "/some" with my home dir, but even still most of these paths don't exist. For instance my ruby installation is from "/Users/davea/.rvm/rubies/ruby-2.5.1/bin/ruby". I have a "/Users/davea/.gem/ruby/2.0.0/" directory but it only has "cache" directory in it. Is there something I need to install?Dipterocarpaceous

© 2022 - 2024 — McMap. All rights reserved.