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

Client doesn't register dependency paths for version managers based on shims #2709

Closed
vinistock opened this issue Oct 10, 2024 · 4 comments · Fixed by #2718
Closed

Client doesn't register dependency paths for version managers based on shims #2709

vinistock opened this issue Oct 10, 2024 · 4 comments · Fixed by #2718
Assignees
Labels
bug Something isn't working vscode This pull request should be included in the VS Code extension's release notes

Comments

@vinistock
Copy link
Member

Reported in #2701

When we configure the client, we use the environment's GEM_PATH to register the language server for handling dependency files, which allows users to enjoy all of our features even inside gems.

However, that approach will not work properly for version managers based on shims, because those will not export a GEM_PATH when running the activation script.

I believe that the solution is to return another field from the activation script for the gem paths (which can be printed with Gem.path). That value will exist even for version managers based on shims, so we can rely on that to register the client paths instead of using the environment variable.

@vinistock vinistock added bug Something isn't working vscode This pull request should be included in the VS Code extension's release notes labels Oct 10, 2024
@vinistock vinistock self-assigned this Oct 12, 2024
@edzhelyov
Copy link

I'm testing the 0.8.6 vscode extension against my local setup where I had the issue and it still doesn't work. I have just updated the Ruby-lsp extension and re-opened the workspace in the devcontainers. I'm attaching a few screenshots.

A complete fresh installation of rails devcontainers by using rails new abc --devcontainer --skip-bundle doesn't work as well.

My concern is that you do a grep replace on the ruby path, but I think rbenv stores the bundler gems in exactly that path you are replacing, haven't tested the actual code, just by reading it.

Extension:

Image

My own code:

Image

Gem file:

Image

@vinistock
Copy link
Member Author

My concern is that you do a grep replace on the ruby path

That is to correct only default gems, not bundled gems.

Let's see if we can diagnose exactly what's going on, what do you get if you run this?

  • ruby -e 'puts Gem.path' # => print your gem paths
  • bundle show rails # => print the place where your gems are installed

@edzhelyov
Copy link

The ruby-lsp server runs in the container.

vscode ➜ /workspaces/abc $ ps aux | grep ruby-lsp
vscode       569  0.0  0.0   2324  1280 ?        S    14:55   0:00 /bin/sh -c ruby-lsp
vscode       570 50.2  1.7 999800 144624 ?       Sl   14:55   0:03 /home/vscode/.rbenv/versions/3.3.5/bin/ruby-lsp
vscode       681 35.7  0.5 508324 48452 ?        Rl   14:55   0:00 /home/vscode/.rbenv/versions/3.3.5/bin/ruby bin/rails runner /home/vscode/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.20/lib/ruby_lsp/ruby_lsp_rails/server.rb start
ruby -e 'puts Gem.path'
/home/vscode/.local/share/gem/ruby/3.3.0
/home/vscode/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0
bundle show rails
/home/vscode/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/rails-7.2.1.1

Are you able to reproduce it on your machine? Because it runs in a devcontainer I would expect that it will won't work on your machine as well.

@vinistock
Copy link
Member Author

Thanks for sharing those paths. #2738 should fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working vscode This pull request should be included in the VS Code extension's release notes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants