ruby-debug / ruby-debug-ide

An interface which glues ruby-debug to IDEs like Eclipse (RDT), NetBeans and RubyMine.
https://www.jetbrains.com/ruby/features/ruby_debugger.html
Other
371 stars 83 forks source link

IDE debugging of apps on Rails 5.2 broken #146

Closed grumBit closed 6 years ago

grumBit commented 6 years ago

Your environment

Expected behavior

In IDE;

Actual behavior

Work around;

Edit [app root]/ config/boot.rb Comment out line;

Debugging now works throughout app as expected.

Notes;

Looking at https://github.com/Shopify/bootsnap/issues/93, I believe this problem occurs due a combination of the following;

NB: The same problem is occurring in other IDE's;

I don't believe this is a ruby-debug-ide issue itself, however, I'm wondering if a change to ruby-debug-ide could address the issue for developers using IDE's?

Also, I wanted to log the problem with a clear title so other Rails developers using IDE's will know what is going on, rather than spending time on searching for answers

(Apologies if my shotgun approach to submitting this issue on multiple repos is poor-form. I'm new to open-source development)

Steps to reproduce the problem

See attached development_machine_installation.txt, then follow steps in expected behaviour section above. development_machine_installation.txt

ViugiNick commented 6 years ago

@grumBit Did you try the workaround, which is described in the ticket (https://youtrack.jetbrains.com/issue/RUBY-20684)

grumBit commented 6 years ago

I tried the earlier comment to not use bootsnap - https://youtrack.jetbrains.com/issue/RUBY-20684#comment=27-2669909, by commenting out bootsnap in boot.rb as per "Work around" above.

I didn't try the second comment to use an alternate debase gem - https://youtrack.jetbrains.com/issue/RUBY-20684#comment=27-2773671

For my purposes, not using bootsnap at all is good enough. Would it help you, for me to try the alternate debase gem?

Because it took me sometime (possibly because I'm new to Rails), I was wondering if a workaround built into ruby-debug-ide on master would help other folks moving to rails 5.2 from going through the same pain of investigating & working around this problem.

ViugiNick commented 6 years ago

@grumBit This fix does not seem to me successful enough for merging it into master (and yes it would be very good if you tried the second approach)

grumBit commented 6 years ago

I totally agree the workaround I've used is not appropriate for merging into ruby-debug-ide. It's just good enough for my purposes (i.e. learning rails).

I'll try using the alternate debase gem and let you know how I go.

grumBit commented 6 years ago

@ViugiNick I installed the alternate debase into my environment, and it did allow the debugger to work.

However, I needed to start using Bundler in order to directly install a gem from a github branch. Alternatively, I could have; cloned the repo, checked-out the branch, built the gem, and installed the gem. Either way, the workaround being on a branch means getting it to work in some environments is tricky.

Also, using the alternate debase means manually editing <app_root_dir>/config/boot.rb, which doesn't seem ideal to me either.

Given the above, what do you think of using the alternate debase as a workaround?

For my purposes, it's easier to just comment out bootsnap from boot.rb.


These are the steps I used to get the alternate debase working;

grumBit commented 6 years ago

@ViugiNick I've just put 2 & 2 together and noticed it's your branch on the debase repo for the workaround! Does this mean you might be merging it into master? If so, that would make the workaround much easier for people to adopt.

nicolasrouanne commented 6 years ago

@ViugiNick +1 Do you have any idea if your quick fix for debase (https://github.com/denofevil/debase/pull/62) would be mergeable any time soon? It would be nice to keep bootsnap and a normal released debase

nicolasrouanne commented 6 years ago

Here is how I got it working on Rails 5.2 and ruby 2.5.1p57

# config/boot.rb
[...]
require 'bootsnap/setup' unless ENV['RUBY_DEBUG_IDE'] == 'true'

And launching my debugger with `RUBY_DEBUG_IDE=true``

For those using VS Code here is my configuration

   {
      "name": "Rails server",
      "type": "Ruby",
      "request": "launch",
      "cwd": "${workspaceRoot}",
      "program": "${workspaceRoot}/bin/rails",
      "args": ["server"],
      "useBundler": true,
      "pathToBundler": "/Users/<username>/.rvm/gems/ruby-2.5.1/wrappers/bundle",
      "env": { "RUBY_DEBUG_IDE": true }
    },

Note that if you use rvm (like me), you need to set useBundler to true. I found my path to bundler by typing which bundle and replacing bin by wrapper in the the PATH as stated in https://github.com/rubyide/vscode-ruby/issues/16#issuecomment-243584600

ycherniavskyi commented 6 years ago

One more possible workaround but without additional environment variable:

# config/boot.rb
[...]
unless defined?(Debugger)
  require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
end
[...]
grumBit commented 6 years ago

@ycherniavskyi Your workaround is very nice! Thank you :).

grumBit commented 6 years ago

@ycherniavskyi It would appear the underlying Ruby issue is fixed in 2.5.2 (ruby/ruby@b85b10c).

Given the problem only existed on Ruby versions 2.5.0 through 2.5.1., perhaps the following workaround would be a keeper?

# config/boot.rb
[...]
unless ( (('2.5.0'..'2.5.1').include? RUBY_VERSION) && defined?(Debugger) )
  require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
end
[...]