Skip to content

VSCode does not pick up stree #341

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

Closed
danbee opened this issue May 22, 2023 · 3 comments
Closed

VSCode does not pick up stree #341

danbee opened this issue May 22, 2023 · 3 comments

Comments

@danbee
Copy link

danbee commented May 22, 2023

Hi, I'm trying to set up our project to use syntax_tree for Ruby code formatting, and I'm having some trouble getting the VSCode extension to consistently pick up the stree executable. If I launch VSCode using the CLI tool (eg. code .) or using the .code-workspace file in our project it all works correctly.

However, if I just launch VSCode directly from the OS (macOS Ventura in this case), I get the following error messages and code formatting does not work.

image
Starting language server: stree lsp
[Error - 3:09:05 PM] Syntax Tree client: couldn't create connection to server.
Launching server using command stree failed. Error: spawn stree ENOENT

syntax_tree is installed in the bundle for the application and also globally. I use asdf for managing Ruby versions on my machine.

If I click on the "Install Gem" button I get an error about permissions:

Error installing gem: Error: Command failed: gem install syntax_tree
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.

This suggests that it's trying to install the gem for the system Ruby version rather than the version of Ruby selected by asdf.

@Frexuz
Copy link

Frexuz commented Aug 5, 2023

Same here

@kddnewton
Copy link
Member

This is a little outside my control unfortunately, so it's mostly dependent on how you set up your system. If it's within a project, clearly it's picking it up correctly. If it's not within a project, then it's going to be dependent on how gem resolves on your system. If you're using something like chruby, rvm, or rbenv, then they all have options to set how the global gem command resolves. I'm sorry I don't know asdf very well, but I'm sure there's a way to make it resolve your correct Ruby versions on login. I would suggest starting there.

@pmusaraj
Copy link

pmusaraj commented Nov 4, 2024

For any passers-by, I found a solution for this. Set up the Ruby LSP extension for VS Code, and then configure it to use the Ruby version manager of your choice. Once that is done, you will still see the same warnings as in the OP, but the Restart button works, it will load stree using the correct Ruby version.

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

4 participants