Looking for advice to get Ruby installed & VSCode configured on Windows 10

Explanation for running the yard command

yard Executable : File: Getting Started Guide — Documentation for yard (0.9.34) (rubydoc.info)

Yeah, there’s a lot going on in that page which is way above my level of understanding at this stage. I can see from the page that the command I used yard gems sketchup-api-stubs should have built a YARD index for gems (whatever that means). I’m not sure whether its actually important that I understand any of that at this stage, however, all I really am interested in is, did the command actually do anything, because there is no indication in the CMD window that it did.

So I think I have followed all the instructions to configure VSCode, however, I don’t believe it’s providing SketchUp-specific Intellisense and I’m now trying to decipher why not. It seems that the behaviour that I’m seeing in these images is the same that I see in my VSCode.

Did you have a look at this?

And this issue is still open …

Hi Neil, thanks for replying.

No I hadn’t seen your topic but I’m glad the issue has been had by others and eventually solved. I’ve read through the thread and I’ve immediately tried what you believed the solution to be. My solargraph.yml file now looks like this:

# To allow solargraph to resolve the require paths correctly, add the path
# to the Tools directory of one of your SketchUp installations.
# You also want to add the path to where you have the extension's sources.
# (In this example it would be in a `src` directory relative to .solargraph.yml)
require_paths:
- "C:/Program Files/SketchUp/SketchUp 2023/Tools"
- "C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems"
- src

# This will load the stubs for the SketchUp API.
require:
- sketchup-api-stubs

# Exclude files that doesn't need to be parsed. Avoids noise and improve performance.
exclude:
- /build/**/*
- /ThirdParty/**/*

I’ve since restarted VSCode but I still do not get anything if I type SketchUp.

Like you, I followed the instructions by entering the 4 commands and also like you, I saw nothing after running yard gems sketchup-api-stubs
I notice that @DanRathbun replied to your query:

with “No” and provided a link to another page with instructions, which shows this:


We both used gem install yard but the original instructions made no mention whatsoever about using gem install yard-sketchup.

Did you perhaps use that command, and did you attempt to use yard gems sketchup-api-stubs again after adding the gems require path to you solargraph.yml file?

Hi Dan, I did find that page yesterday but the content discussed makes no sense to me.

FYI, the yard-sketchup gem is the YARD template that is used for generating local HTML documentation output that is also posted at ruby.sketchup.com website. Locally this is used by the yard doc command.

The code for the template is in repository: https://github.com/SketchUp/sketchup-yard-template
This is just for general info, you do not need to worry about the inner workings of YARD for now.

It wouldn’t hurt to install the template gem. The snips of VSCode showing the popup docs (in the GitHub topics) do look very similar to YARD generated output. But I don’t know if it’s YARD, Solorgraph or what generating these popups.

Hi Dan,
I’ve since ran that command and also yard gems sketchup-api-stubs which again displays absolutely nothing in the CMD window. I really don’t know where to go from here, its just so bloody frustrating that something like this is so difficult. @tt_su Do you have any suggestions how to solve this problem?

So I managed to make some progress and eventually have the Intellisense appearing that I have seen in screenshots in other topics. Having been off for a week on holiday, I was hoping to finally get started this morning, however, when I loaded up VSCode, I was notified that the Ruby extension I had installed (as per the instructions here) is now listed as deprecated and that I should be using the Ruby LSP extension instead.
image
If I migrate to that, then this message appears:
image
It’s my understanding that I can’t have a version of Ruby installed that is greater than 2.7.7 so the obvious question is, what do we do now?

Incorrect. Each standalone Ruby version installs into it’s own versioned subfolder.

I have at least 3 standalone “system” Ruby versions installed on my computer.
There are several Ruby version manager utilities available to tell your computer which one to use as the default.
They are listed in my Ruby Resources listing in the REFERENCE list under Ruby Generic References.
For Windows I use uru. (See the link in the list.)

So, go ahead and install Ruby version 3.2.2-p53 (or a newer patch level of Ruby 3.2.2).

Then adjust any of the VSCode or project settings files to point to the 3.2.2 path.

Please open an issue for the wiki to be updated for the newer VSCode plugin at:

Hi Dan,

I didn’t mean that we cannot install multiple versions of the language itself, Perhaps I should explain the comment clearer. It was my understanding that from what you told me before:

…is that Extension developers don’t use Ruby version’s newer than what SketchUp uses. This would make sense, perhaps to avoid any problems that newer versions of Ruby might have with SketchUp and similar rules happen within development of other CAD software e.g. using only specifics version of Visual Studio to compile an application to be used in a certain version of the software. However, if I can install a newer version without it causing any problems then I’m happy to do so, but I wouldn’t know if that were the case or not. I’m surprised the extension deprecation hasn’t already been mentioned here already.

Yes … but … SketchUp development is not static and endeavors to update it’s embedded Ruby version every 2 or 3 major releases.

So, … it’s that time again for the next release. You are getting a “head’s up”. Write for 3.2.2 and your extension will be ready for SU2024. (But try not to use syntax or method calls that will break in Ruby 2.x. if you want your extension to be backward compatible for older SketchUp versions.)

Also, the standalone system Ruby install is only used for running the VSCode plugin(s) for IntelliSense, etc. They will never be used by SketchUp., which always loads it’s own Ruby package (or framework.)

Note that the VSCode plugin was only “deprecated.” It and Ruby 2.7.7 should still be usable. You might need to ignore or suppress the warning.

The SketchUp embedded Ruby version has always lagged behind the rest of the Ruby world in the version that it uses. Mainly because of the time and cost of testing; also, the number of developers and extensions that need to be tested on newer Ruby versions. It is more economical to stay on a known stable version for a few years.

But this causes the SketchUp’s Ruby version to be either deprecated or at end of life by the time Trimble gets around to updating its embedded version.

1 Like

So I uninstalled the existing Ruby installation and installed 3.2.2. I then had to run the previous commands to get the API Stubs to work and also ensure the require paths are correct for my solargraph.yml file, however, I am getting this error.
image
I have already installed solargraph and verified its installation. The output error makes no sense to me:


Do you have any idea what might be wrong?

Looking at the Ruby error message, it is Exception subclass ENOENT which is Ruby’s cryptic acronym for "no entry (in directory). "

So, it appears that Solargraph cannot find a file it is looking for.

FYI: You can have multiple Ruby versions installed. And use uru to select which one is active.

Hmm well I guess my next option will be to ask the author of Solargraph what the problem is. I couldn’t see anything on the extension page that mentioned version compatibility with Ruby.

At this early stage, I just want one version that will let me get started . I’m not sure if I’ll ever need multiple versions but I can appreciate that for advanced users like yourself, that it could be beneficial.

Make sure that you do not have any paths for the uninstalled Ruby version still in your %PATH% environment variable.

On https://solargraph.org/guides it lists Ruby 2.1.0 or higher. (But likely this page is out of date.)

The gem page at rubygems.org shows Ruby 2.6 or higher.

The code repository at: GitHub - castwide/solargraph: A Ruby language server. has 114 open issues.


The vscode-solargraph plugin repository has 76 open issues.


The error you are getting appears to be happening in a node-js module called ruby-spawn, the latest version is 1.3.0 which the vscode-solargraph plugin requires (see views/pakage-lock.json:line 5012.)

I noticed this morning that I am not getting the same error as I was yesterday. I can only guess that the reboot has resolved whatever issue I was having. However, a new set or errors have now appeared:
image

The output error is rather extensive, but repetitive:

Project contains a Gemfile, but no Gemfile.lock. Run bundle install to lock gems and restart the server
[Error - 12:21:56 PM] Server process exited with code 78.
[Error - 12:21:56 PM] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Info - 12:21:56 PM] Connection to server got closed. Server will restart.
true
[Error - 12:21:56 PM] Ruby LSP client: couldn’t create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
Project contains a Gemfile, but no Gemfile.lock. Run bundle install to lock gems and restart the server
[Error - 12:21:56 PM] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Info - 12:21:56 PM] Connection to server got closed. Server will restart.
true
[Error - 12:21:56 PM] Ruby LSP client: couldn’t create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
Error restarting the server: Pending response rejected since connection got disposed
[Error - 12:21:56 PM] Server process exited with code 78.
Project contains a Gemfile, but no Gemfile.lock. Run bundle install to lock gems and restart the server
[Error - 12:21:57 PM] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Info - 12:21:57 PM] Connection to server got closed. Server will restart.
true
[Error - 12:21:57 PM] Ruby LSP client: couldn’t create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 12:21:57 PM] Restarting server failed
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 12:21:57 PM] Server process exited with code 78.
Project contains a Gemfile, but no Gemfile.lock. Run bundle install to lock gems and restart the server
[Error - 12:21:57 PM] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Info - 12:21:57 PM] Connection to server got closed. Server will restart.
true
[Error - 12:21:57 PM] Ruby LSP client: couldn’t create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 12:21:57 PM] Restarting server failed
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 12:21:57 PM] Server process exited with code 78.
Project contains a Gemfile, but no Gemfile.lock. Run bundle install to lock gems and restart the server
[Error - 12:21:58 PM] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 12:21:58 PM] The Ruby LSP server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
[Error - 12:21:58 PM] Ruby LSP client: couldn’t create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 12:21:58 PM] Restarting server failed
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 12:21:58 PM] Server process exited with code 78.

Interestingly, the error says there is a Gemfile, yet I don’t have one in my test project.

To my knowledge, this particular extension hasn’t been used previously for SU extension development, it was the other one that is now listed as deprecated. I’m wondering if I’m better off just reinstalling that and wait till any guides are updated to detail the installation process steps and requirements for working with the Ruby LSP extension.