castwide / vscode-solargraph

A Visual Studio Code extension for Solargraph.
Other
424 stars 25 forks source link

VSCode Solargraph + RVM using wrong Ruby framework #243

Open phroph opened 2 years ago

phroph commented 2 years ago

I have what seems like a regression of an older bug when using RVM: https://github.com/castwide/vscode-solargraph/issues/63

I can see that in all terminals, windows (including VS term), ruby is properly set to 2.7.5, and solargraph is working.

I've tried:

I have (according to VS terminal):

I just get a message along the lines of (without using bundler)

System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/dependency.rb:311:in `to_specs': Could not find 'benchmark' (>= 0) among 374 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/Users/phuff/.rvm/gems/ruby-2.7.5:/Users/phuff/.rvm/rubies/ruby-2.7.5/lib/ruby/gems/2.7.0', execute `gem env` for more information
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.rb:1449:in `block in activate_dependencies'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.rb:1438:in `each'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.rb:1438:in `activate_dependencies'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.rb:1420:in `activate'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:304:in `block in activate_bin_path'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:303:in `synchronize'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:303:in `activate_bin_path'
    from /Users/phuff/.rvm/gems/ruby-2.7.5/bin/solargraph:23:in `<main>'
    from /Users/phuff/.rvm/gems/ruby-2.7.5/bin/ruby_executable_hooks:22:in `eval'
    from /Users/phuff/.rvm/gems/ruby-2.7.5/bin/ruby_executable_hooks:22:in `<main>'

Clearly it's hitting the correct solargraph executable and then immediately using the Ruby.framework 2.6 activate_bin_path. My workspace also has .ruby-version which is correctly set to 2.7.5.

Not sure where to go from here because the linked original ticket involves making a change to a utils file in node_modules, but I don't see that anymore (also it's been more than 3 years since that ticket).

alanwilter commented 2 years ago

I have the same issue. Using macOS 11.6.5.

VSCode

Version: 1.66.2
Commit: dfd34e8260c270da74b5c2d86d61aee4b6d56977
Date: 2022-04-11T07:49:20.994Z
Electron: 17.2.0
Chromium: 98.0.4758.109
Node.js: 16.13.0
V8: 9.8.177.11-electron.0
OS: Darwin x64 20.6.0

Ruby setup

ruby 3.2.0preview1 (2022-04-03 master f801386f0c) [x86_64-darwin20]
solargraph 0.44.3
.ruby-version ruby-3.2.0
alanwilter commented 2 years ago

It's now working and the solution is to use "wrappers".

VSCode settings.json:

  "solargraph.transport": "stdio",
  "solargraph.formatting": true,
  "solargraph.diagnostics": true,
  "solargraph.commandPath": "/Users/alan/.rvm/wrappers/default/solargraph",
phroph commented 2 years ago

Nice find! I'll give that a shot when I have a chance and see if that resolves my issue. I had bit the bullet and was using RubyMine in the short-term, rather than fiddle with this too much.

denkoleda commented 1 year ago

Huge thanks @alanwilter! I've spend more than an hour trying to wrap my head around it...