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

LSP is looking for missing gem but gem is already installed. #1863

Closed
lightweightcoder opened this issue Apr 2, 2024 · 4 comments · Fixed by #1868
Closed

LSP is looking for missing gem but gem is already installed. #1863

lightweightcoder opened this issue Apr 2, 2024 · 4 comments · Fixed by #1868
Labels
bug Something isn't working

Comments

@lightweightcoder
Copy link

lightweightcoder commented Apr 2, 2024

Description

I opened a ruby file, rubyLSP tries to start -> looks for missing gems and realises that mysql2 (0.5.3) is missing so it tries to install it but fails at installation step. This happened only today and I did not update the gem. I think LSP is looking at a different folder for the gem.

Expected Behaviour

  • rubyLSP should be able to find the gem so it does not need to install it.

System / Project specs

  • Ruby LSP VS Code extension: v0.5.16.
  • Using rvm 1.29.12 to manage my ruby version.
  • bundle --version shows 2.3.7
  • ruby --version shows 3.1.1p18
  • echo $GEM_HOME shows /Users/aljt/.rvm/gems/ruby-3.1.1
  • echo $GEM_PATH shows /Users/aljt/.rvm/gems/ruby-3.1.1:/Users/aljt/.rvm/gems/ruby-3.1.1@global
  • echo $RUBY_VERSION shows ruby-3.1.1
  • ruby -e 'puts [Gem.user_dir, Gem.default_dir]' shows
    /Users/aljt/.gem/ruby/3.1.0
    /Users/aljt/.rvm/rubies/ruby-3.1.1/lib/ruby/gems/3.1.0
  • bundle info mysql2 shows the path is /Users/aljt/.rvm/gems/ruby-3.1.1/gems/mysql2-0.5.3

VScode output logs from LSP

The GEM_HOME and GEM_PATH variables are different from the ones I ran in the terminal using echo

Activated Ruby environment: GEM_HOME=/Users/aljt/.gem/ruby/3.1.0 GEM_PATH=/Users/aljt/.gem/ruby/3.1.0:/Users/aljt/.rvm/rubies/ruby-3.1.1/lib/ruby/gems/3.1.0 PATH=/Users/aljt/.gem/ruby/3.1.0/bin:/Users/aljt/.rvm/rubies/ruby-3.1.1/lib/ruby/gems/3.1.0/bin:/Users/aljt/.rvm/rubies/ruby-3.1.1/bin:/Users/aljt/.rvm/gems/ruby-3.1.1/bin:/Users/aljt/.rvm/gems/ruby-3.1.1@global/bin:/Users/aljt/.rvm/rubies/ruby-3.1.1/bin:/Users/aljt/.nvm/versions/node/v12.20.0/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/aljt/.rvm/bin

...some logs...

The following gems are missing
 * mysql2 (0.5.3)
Install missing gems with `bundle install`

...some logs...

An error occurred while installing mysql2 (0.5.3), and Bundler cannot continue.
In Gemfile:
  mysql2

/Users/aljt/.rvm/rubies/ruby-3.1.1/lib/ruby/3.1.0/bundler/definition.rb:481:in `materialize': Could not find mysql2-0.5.3 in any of the sources (Bundler::GemNotFound)

... more logs...

Troubleshooting

  • Tried to uninstall the extension, deleted the .ruby-lsp folder and reinstalled but did not work.
@lightweightcoder lightweightcoder added the bug Something isn't working label Apr 2, 2024
@rafasoares
Copy link

I'm seeing the same issue, but with iconv.

Running BUNDLE_GEMFILE=.ruby-lsp/Gemfile bundle install from the project root succeeds (but the LSP still doesn't work).

I've tried forcing the version manager to RVM, no change.

I rolled back to v0.5.15 and it works.

@vinistock
Copy link
Member

vinistock commented Apr 2, 2024

We just released https://github.com/Shopify/ruby-lsp/releases/tag/vscode-ruby-lsp-v0.5.17, with some RVM fixes. Can you please give it a try and let us know if the issue has been fixed?

@lightweightcoder
Copy link
Author

@vinistock Yup it works now. Thank you for fixing it quickly! 🚀

@rafasoares
Copy link

Sorry @vinistock, I missed the notification from this thread.
I'm on 0.5.21 and I have no issues at the moment :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants