![rubymine rails debug rubymine rails debug](https://europepmc.github.io/techblog/images/posts/rubymine-remote-debug-rails-in-docker/debugger-settings.png)
![rubymine rails debug rubymine rails debug](https://i.stack.imgur.com/Z8E95.png)
Anyway, time for me to stop blabbing on and actually give you some information. Setting it up is actually really easy, as some awesome people have made some plugins and gems for us to use.
RUBYMINE RAILS DEBUG INSTALL
So the first thing to do is install the Ruby plugin in VS Code. This plugin does much more that just enabling debugging, but I’ll let you find that out for yourself, the information on the plugin’s page is a good start. Once that is done, we need to install the gems that actually do the debugging that the IDE can use to display. Rubymine rails debug install#ĭepending on the version of Ruby you are using you will need to install slightly different gems. Once you have installed the gems for the version of Ruby you are using you are pretty much there, now you just need to run the Rails server in debug mode and it's done.
RUBYMINE RAILS DEBUG CODE
Go to the debug tab on VS Code and click the gear icon. That will open the launch.json file which should have a load of configurations marked with type: "Ruby" and, if there aren’t any for some magical reason, then you can add them manually. In case something weird happens to you the configuration for debugging a Rails server is found below. That should do it! Now if you click run with the Rails server option selected in the drop down it will start up in debug mode and a little menu will appear at the top of the screen with debug options such as continue and step over. The bar at the bottom of the window even changes color to indicate it is in debug mode. Now that the server has been started in debug mode, we can add some breakpoints to step into the code and see what is happening. So I have put a breakpoint into my code (please don’t make any comments on my code!) and let's see what happens.
RUBYMINE RAILS DEBUG HOW TO
If you don’t know how to add a breakpoint, just click to the left of the line number that you want it on and then the dot will appear like in the image above. I am pretty sure the dot will always be red, but I am not 100% sure that it can’t be changed through themes. Now if I call this method it will pause when it reaches the breakpoint. Tests will open a debugging shell when they cross a breakpoint set with debugger.If you were in a browser it should open VS Code and wait for your next move.Īt this point, you can decide to just carry on normal execution by pressing continue (f5) or step over (f10), there are a few more options, but I’m too lazy to write them down. When you run RSpec or Cucumber, Ruby is already in debug mode. Debug without Rubymine if you need to do so. Unfortunately you cannot execute arbitrary code in irb while debugging in RubyMine.You can now step through the code with buttons.There is an icon that runs the server in debug mode.To set a breakpoint, click on an area left to the code.
![rubymine rails debug rubymine rails debug](https://resources.jetbrains.com/help/img/idea/2020.3/rm_debug_js_pause.png)
up 3 will take you 3 levels higher in the caller stack. To some commands you may pass a number, e.g. Help ( h) – pass a command for specific help Up ( u) Go one level down in the caller stack without moving the debuggerĭown Add a new breakpoint from an existing debugger sessionįor example: break app/models/user.rb:42 (path names can be relative and absolute) Notepad – its content will be displayed when the program stopsĭisplay – print expression list Reload source code That shell will be running an irb session where you can step through the code, inspect context and watch variables by typing commands.Ĭommands available on the debug shell (with short commands) Run until program ends, hits a breakpoint or reaches line nnnĬontinue ( c) – you may pass a line number Step over the current lineīacktrace ( bt) Go one level up in the caller stack without moving the debugger
![rubymine rails debug rubymine rails debug](https://resources.jetbrains.com/help/img/idea/2021.2/rm_ruby_remote_debug_example.png)
Once you reach the breakpoint, the page loading will seem to "hang".Open your application in the browser and run the code path that crosses the breakpoint.Set a breakpoint by invoking debugger anywhere in your code.Start your server with script/server -debugger.gem install ruby-debug (Ruby 1.8) or gem install debugger (Ruby 1.9).This is an awesome gadget in your toolbox, even if your test coverage is great.