castwide / vscode-solargraph

A Visual Studio Code extension for Solargraph.
Other
425 stars 24 forks source link

solargraph.commandPath not picking the gem from mentioned RVM location #60

Closed aruprakshit closed 5 years ago

aruprakshit commented 6 years ago

Hi,

I do have below settings:

{
  // Basic settings: turn linter(s) on
  "ruby.lint": {
    "reek": true,
    "rubocop": {
      "lint": true,
      "rails": true
    },
    "ruby": true, //Runs ruby -wc
    "fasterer": true,
    "debride": true,
    "ruby-lint": true
  },
  // Time (ms) to wait after keypress before running enabled linters. Ensures
  // linters are only run when typing has finished and not for every keypress
  "ruby.lintDebounceTime": 500,
  "ruby.format": "rubocop",
  "solargraph.formatting": true,
  "solargraph.autoformat": true,
  "solargraph.completion": true,
  "solargraph.commandPath": "/Users/aruprakshit/.rvm/gems/ruby-2.3.3@global/bin/solargraph"
}

But when I open the folder in my editor (VSCode), I see below error:

screen shot 2018-06-04 at 3 38 57 pm
castwide commented 6 years ago

It looks like there's a discrepancy between the version of Ruby you're trying to use (2.3) and the version getting used from VS Code (based on the error message, 2.4). I'm guessing the system/default version is 2.4?

You should be able to specify which version Solargraph should use from VS Code by adding a .ruby-version file to your workspace.

aruprakshit commented 6 years ago

@castwide I already hardcoded it as you see "solargraph.commandPath": "/Users/aruprakshit/.rvm/gems/ruby-2.3.3@global/bin/solargraph", but still it is not picking up.

castwide commented 6 years ago

That's why I suggested a .ruby-version file. The error indicates that VS Code is correctly running the solargraph script in 2.3, but it's using the 2.4 interpreter. Testing from the command line on CentOS, I got the same error using an absolute path to an installation of solargraph that didn't match the version of Ruby in use via rvm. The gem's executable doesn't change the interpreter.

I can try some more tests on MacOS later. I don't think I've ever set solargraph.commandPath in conjunction with systems using rvm. I've only ever needed it on certain Windows setups.

aruprakshit commented 6 years ago

@castwide I'll try and let you know.

aruprakshit commented 6 years ago

@castwide I removed solargraph.commandPath and added .ruby-version. Now it is working. Is .ruby-version needed as I am using RVM?

castwide commented 6 years ago

@aruprakshit It's the easiest way I know to select a Ruby version other than the system default.