VS Code Debugging set up on Mac

Hey all. I am trying to figure out how to set up the debugger in VS Code. The ruby extension referenced here is no longer available. The recommended replacement Ruby LSP tells me that my project is in ruby 2.6.10 and ruby 3.0 is required. What Ruby extension should I be using? Any tips for a first time set up appreciated as well… Thanks!

I decided to pass on setting up debugging (maybe a poor choice?) and just use puts statements and console logs.

But search the forum for a “reloader”. I haven’t set one up yet (maybe another poor choice?) but that’s on my ToDo as I’m restarting SketchUp enough to know I’m not making things easy on myself ;^)!

2 Likes

Ya thats what I am doing currently. I was wondering if there is any big benefit to workflow using the debugger. Also now that I started the setup its bothering me that I can’t finish it lol.

Fixed Link:
Link to reloader mentioned above.

Looks like you’re on top of it (but the link does not seem to be working).

It looked like getting it set up would be a pain… but I’m a KISS level user.

1 Like

I got rid of the errors from Ruby LSP by using rvm to install Ruby 3.1.2 and set it as default. I tried Ruby 3.2 but could not get it to build due to an error in the openssl code. So far I haven’t seen further errors from VSCode.

1 Like

Will try thanks!

P.S. what’s rvm?

Its the ruby version manager. The official ways to get it are listed here.

2 Likes

OK great thanks!

Checking RUBY_VERSION in SketchUp 2023 (23.1.341) returns "2.7.7". Since functionality can change significantly across major version changes, there’s some risk of things not working if you develop with a different version than what SketchUp uses. I’m just starting to look now; has anyone already seen a way to use 2.7.7 with Ruby LSP?

So far, I haven’t run into any issues with VSCode set up to use Ruby 3.1.2. There may be some, I just haven’t hit them yet…

I think Ruby LSP is itself implemented using features of Ruby 3, so I doubt it can be adapted to work with Ruby 2.7 though I’d be interested in hearing if anyone manages to get it going. The downside of the mismatch is that Ruby LSP might flag an error on syntax that is legal in 2.7 or allow you to write code that 2.7 will reject.

For me, a bigger issue is that Ruby LSP does not include the remote debugger ide support that was in the former engine. Until somebody figures out how to do that, it is impossible to do live debugging of SketchUp from VSCode! I’ve had to go back to the old puts technique, which is murder if you are trying to debug a Tool, especially #onMouseMove, which gets called a zillion times!

1 Like

Thanks. I actually had some new plugin code fail for SketchUp 2018 recently, because of differences between SketchUp 2018’s Ruby 2.2.4 and SketchUp 2023’s Ruby 2.7.7. So, this kind of problem may not be as far-fetched as one would imagine.

In my experience, there is a bigger issue with new code using new features of the Ruby API than with different Ruby versions. And on Mac, with old versions of SketchUp being unstable on newer versions of macOS. But I tend to write relatively straightforward syntax rather than jumping on the latest sexy language features. YMMV. Until I try to run it on an old version of SketchUp, I never assume that new code will work correctly!

And the editor isn’t actually running your code, it is performing a static analysis of the code. In case of a version mismatch, it may flag something as an error that used to be ok or accept something that older Ruby can’t understand, but that won’t prevent you from saving and testing your code on an actual SketchUp version. Of course, testing on each old version of SketchUp takes a lot of time. That’s a big reason why many extension authors support only the last three versions of SketchUp (and perhaps Make 2017).

OK. I was actually just referring to the fact that a straightforward method call on Fixnum that exists in Ruby 2.7.7 doesn’t exist in Ruby 2.2.4. Hardly sexy stuff. But it’s a good point that this VSC plugin is just analyzing the code, not running it.

FYI: You can browse the Ruby NEWS for each major.minor release at:

Use the left navigation pane to change version.

1 Like

Bignum and Fixnum no longer exist as defined classes in Ruby 2.4.0 and higher.
They are now merely constant aliases for the Integer class.

Fixnum.name
#=> "Integer"

See: NEWS-2.4.0 - Documentation for Ruby 3.2

It’s worth mentioning that the only reason I made this breaking change in the first place was that the Rubocop linter had suggested it. Let this be a cautionary tale!