Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugger doesn't seem to work any more with Ruby 3.3 #16

Closed
NigelSwinson opened this issue Mar 15, 2024 · 2 comments
Closed

Debugger doesn't seem to work any more with Ruby 3.3 #16

NigelSwinson opened this issue Mar 15, 2024 · 2 comments

Comments

@NigelSwinson
Copy link

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

There are two issues in this report. Am uncertain which if either should be filed against readapt rather than solargraph. I filed PyvesB/eclipse-solargraph#31 and they seem to think the first issue is because a fix hasn't been published, and think the second issue is with the Readapt code.

First issue: The latest Solargraph seems to pull down a readapt version which is missing the rb_cData with rb_cObject fix:
7b209fe

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:in require'

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:in require'\n<full path to one of my rb files>:2:in `<top (require","category":"stderr"}}Content-Length: 333

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

@castwide
Copy link
Owner

Fix released in v3.0.0. If problems persist, please refer to #14.

@NigelSwinson
Copy link
Author

The first issue, which relates to #14 has indeed been resolved, but the second issue remains.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants