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

Question about the setup of solargraph.commandPath #16

Open
aruprakshit opened this issue Sep 2, 2019 · 7 comments
Open

Question about the setup of solargraph.commandPath #16

aruprakshit opened this issue Sep 2, 2019 · 7 comments

Comments

@aruprakshit
Copy link

solargraph.commandPath:

Path to the solargraph command. Set this to an absolute path to select from multiple installed Ruby versions.

I am using Rvm. How do I set up it to an absolute path, so that it can be found out across all the ruby versions? Do I need to install the gem for each ruby versions I have installed?

@AlanWarren
Copy link

AlanWarren commented Sep 4, 2019

There are a few ways to handle this. I use rvm, and this is what I do.

I install solargraph from a shell that uses my default version of ruby. i.e. gem install solargraph

My global coc configuration (edit with :CocConfig) contains:
"solargraph.useBundler": false,

For my projects that I manage with a Gemfile (and perhaps use .ruby-version), I'll add solargraph to my Gemfile, and let bundler manage the installation. i.e. bundle install or bundle update solargraph

For this to work, I add a "workspace" configuration file (.vim/coc-settings.json) within my project, and it contains

{
  "solargraph.useBundler": true,
}

(see https://github.com/neoclide/coc.nvim/wiki/Using-the-configuration-file )

So, you will end up with multiple solargraph gems on your system. Globally, and for each project.

However, the only reason I do this, is because I often edit ruby code that I do not manage with a Gemfile. For example, vagrant's configuration is done using ruby, and I like for solargraph to work everywhere. If you only code ruby from projects with a Gemfile, then you don't need to do all of this. Just set useBundler: true and bundle install.

Caveat - If you use ZSH as your shell, make sure you source the RVM environment inside of your ~/.zprofile and not your ~/.zshrc.

@chemzqm
Copy link
Member

chemzqm commented Sep 10, 2019

I don't like rvm since it change global environment, use a single global solargraph is recommended.

@aruprakshit
Copy link
Author

@chemzqm How do you install a global one when you have rvm installed, that would be great to know.

@chemzqm
Copy link
Member

chemzqm commented Sep 10, 2019

Don't know, I don't use rvm.

@AlanWarren
Copy link

@chemzqm How do you install a global one when you have rvm installed, that would be great to know.

If you are using rvm with a single version of ruby, you should have no problem using a global solargraph gem.

The caveats are gemsets and different ruby versions. If you are switching ruby versions on a project basis, etc., then you will need to gem install solargraph for each version of ruby you plan on using.

If you are using gemsets, then you will need to install solargraph for each gemset.

Otherwise, it should work fine.

@sameera207
Copy link

@aruprakshit , What @AlanWarren said is right,

With rvm you can install solargraph to the global gemset

rvm @global do gem install solargraph

However, the issue is, here global is scoped by the ruby version. (means, you'll have to install solargraph for each ruby version globally)

Another option is (How I have done), is to give the command path , following is my coc-settings.json

#coc-settings.json
{
  "suggest.echodocSupport": true,
  "suggest.maxCompleteItemCount": 20,
  "coc.preferences.formatOnSaveFiletypes": [
    "javascript",
    "typescript",
    "typescriptreact",
    "json",
    "javascriptreact"
  ],
  "tsserver.log": "verbose",
  "tsserver.trace.server": "verbose",
  "eslint.filetypes": [
    "javascript",
    "typescript",
    "typescriptreact",
    "javascriptreact"
  ],
  "diagnostic.errorSign": "•",
  "diagnostic.warningSign": "•",
  "diagnostic.infoSign": "•",
  "solargraph.commandPath": "/Users/<username>/.rvm/gems/ruby-2.4.3/bin/solargraph"
}

@matt961
Copy link

matt961 commented Jan 3, 2020

For anyone still struggling with this and using RVM, I found that ~/.rvm/gems/ruby-x.y.z/bin/solargraph was actually pointing to the wrong version even though I have the most recent version installed (I think it was something to do with .ruby-version and rvm switching automatically to a different version with the outdated solargraph gem). Using ~/.rvm/gems/ruby-x.y.z/wrappers/solargraph gave me the correct gem version. Had to do this to get nvim-qt working properly.

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

5 participants