PyvesB / eclipse-solargraph

:gem: Ruby development tools for Eclipse.
https://marketplace.eclipse.org/content/ruby-solargraph
Eclipse Public License 2.0
30 stars 6 forks source link

Debugger doesn't seem to work with Ruby 3.3 #31

Open NigelSwinson opened 8 months ago

NigelSwinson commented 8 months ago

Solargraph struggles to access a readapt which even runs, and when that is resolved, the solution doesn't actually work.

Apologies, fumbled keyboard, the detailed bug report is in the next post

NigelSwinson commented 8 months ago

There are two issues in this report. Am uncertain which if either should be filed against readapt rather than solargraph.

First issue: The latest Solargraph seems to pull down a readapt version which is missing the rb_cData with rb_cObject fix: https://github.com/castwide/readapt/commit/7b209fe7efe78e4f568da04c4b89056fa90973a6

This means the native extension does not compile.

c:\Ruby33-x64\lib\ruby\gems>gem install readapt Fetching readapt-1.4.4.gem Temporarily enhancing PATH for MSYS/MINGW... Building native extensions. This could take a while... ERROR: Error installing readapt: ERROR: Failed to build gem native extension. current directory: C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/readapt-1.4.4/ext/readapt C:/Ruby33-x64/bin/ruby.exe extconf.rb creating Makefile

current directory: C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/readapt-1.4.4/ext/readapt make DESTDIR\= sitearchdir\=./.gem.20240310-22128-j61oje sitelibdir\=./.gem.20240310-22128-j61oje clean

current directory: C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/readapt-1.4.4/ext/readapt make DESTDIR\= sitearchdir\=./.gem.20240310-22128-j61oje sitelibdir\=./.gem.20240310-22128-j61oje generating readapt-x64-mingw-ucrt.def compiling breakpoints.c compiling frame.c frame.c: In function 'initialize_frame': frame.c:131:57: error: 'rb_cData' undeclared (first use in this function) 131 | c_Frame = rb_define_class_under(m_Readapt, "Frame", rb_cData); | ^~~~ frame.c:131:57: note: each undeclared identifier is reported only once for each function it appears in make: *** [Makefile:248: frame.o] Error 1

make failed, exit code 2

Gem files will remain installed in C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/readapt-1.4.4 for inspection. Results logged to C:/Ruby33-x64/lib/ruby/gems/3.3.0/extensions/x64-mingw-ucrt/3.3.0/readapt-1.4.4/gem_make.out

I was able to get round this with help from https://stackoverflow.com/questions/16310793/how-to-avoid-the-source-being-overwritten-when-compiling-a-gem:

  1. doing a git clone from https://github.com/castwide/readapt (the head source does have the repair)
  2. gem build readapt.gemspec
  3. gem install readapt-1.4.4.gem

But then hit second issue.

Second issue: trying to start the debugger triggers these errors.

[TypeError] no implicit conversion of nil into String <internal:C:/Ruby33-x64/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in require' <internal:C:/Ruby33-x64/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:inrequire'

I happen to be debugging a selenium test, which runs fine in Ruby directly (the thing I am troubleshooting connects to a DOM change in what I'm running against), but triggers this error when I try to run through Eclipse/SolarGraph/Readapt, meaning I don't get any interactive debugging.

The fault reproduces with this trivial rb file. Runs cleanly with 100% passed when run directly, but produces the error when run through solargraph/readapt

require "test/unit"

class Noop < Test::Unit::TestCase def setup end

def teardown end

def test_main end end

It is not helped by the fact one of the messages gets truncated. There seems to be some kind of 355 character limit in the "output" lines. Eventually I found the Solargraph "Troubleshoot Readapt debugger by enabling adapter logs" checkbox. Hard to work out where this was going to put log messages, but eventually found the debug adapter logs had turned into JSON rather than raw text. But there's no real extra content:

Content-Length: 344

{"type":"response","request_seq":1,"success":true,"command":"initialize","body":{"supportsConfigurationDoneRequest":true,"exceptionBreakpointFilters":[{"filter":"raise","label":"Break on raised exceptions","description":"The debugger will break when an exception is raised, regardless of whether it is subsequently rescued.","default":false}]}}Content-Length: 38

{"type":"event","event":"initialized"}Content-Length: 79

{"type":"response","request_seq":2,"success":true,"command":"launch","body":{}}Content-Length: 90

{"type":"response","request_seq":3,"success":true,"command":"configurationDone","body":{}}Content-Length: 108

{"type":"event","event":"process","body":{"name":"\<the full path to my rb file>"}}Content-Length: 74

{"type":"event","event":"thread","body":{"reason":"started","threadId":1}}Content-Length: 74

{"type":"event","event":"thread","body":{"reason":"started","threadId":1}}Content-Length: 129

{"type":"event","event":"output","body":{"output":"[TypeError] no implicit conversion of nil into String\n","category":"stderr"}}Content-Length: 331

{"type":"event","event":"output","body":{"output":"\<internal:C:/Ruby33-x64/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in require'\n\<internal:C:/Ruby33-x64/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb\>:127:inrequire'\n\:2:in `<top (require","category":"stderr"}}Content-Length: 333

I've been using these extensions without too much trouble for years (5?!?), and have very much appreciated them, so am sad they have now broken, and am hopeful repair isn't too difficult?

PyvesB commented 8 months ago

Hello @NigelSwinson! 👋🏻

Sorry to hear the debugger isn't working properly anymore.

As far as the first issue is concerned, unfortunately the fix you linked to hasn't yet been published. I've pinged the author in https://github.com/castwide/readapt/pull/15.

As far as the second issue is concerned, I'm honestly not too sure. It's rather unlikely that this is an issue with the Eclipse plugin, I think the best course of action is to create an issue in the Readapt repository. :)

NigelSwinson commented 8 months ago

Created https://github.com/castwide/readapt/issues/16 with them to cross reference this. If you are confident there is no problem with solargraph, and resolution is all with the readapt code base, then it may make sense to just close this issue. But it does seem at the moment that Solargraph is pointing users to software which doesn't work, which isn't great for Solargraph either.

castwide commented 8 months ago

Readapt v2.0.0 includes the fix for this issue.