nvim-lspinstall icon indicating copy to clipboard operation
nvim-lspinstall copied to clipboard

Ruby (Solargraph) Install Modifies Local Bundle Config

Open jherdman opened this issue 2 years ago • 6 comments

When installing the Ruby LSP (solargraph) it modifies one's local bundle config. This has surprising consequences. One of the flags used is --without development. This is unfortunate as one's Gemfile may very well have development only gems configured, e.g. Spring.

Unfortunately the aforementioned before is the default behaviour for Bundler. This means that the state of --without needs to be remembered before issuing said command. Further, since one may already have a --path option set it is prudent to first check if it needs to be issued at all.

jherdman avatar Jul 15 '21 13:07 jherdman

are you sure? the script is executed in a different directory. it shouldn't modify anything in your pwd. 🤔

kabouzeid avatar Jul 15 '21 18:07 kabouzeid

Absolutely 100% sure. I was bitten by this pretty hard earlier this week when all of my...

group :development do
  # blah
end

gems didn't install. I verified this after reverting changes to my .bundle/config and then running :LspInstall ruby again. Same problem.

jherdman avatar Jul 15 '21 18:07 jherdman

Sorry that this happened! I don't know anything about ruby. If you know how to fix this, feel free to make a PR. Otherwise a minimal ruby project and steps to reproduce would be good, maybe I can fix it then :)

kabouzeid avatar Jul 15 '21 18:07 kabouzeid

I'll see what I can do. My Lua is pretty weak so far. I think, though that the below code is more or less just a string that's executed as a shell script. Correct?

https://github.com/kabouzeid/nvim-lspinstall/blob/f8877c92fa1d0b9e1c25478cfc45a2c0c7029060/lua/lspinstall/servers/ruby.lua#L4-L21

jherdman avatar Jul 15 '21 18:07 jherdman

Yes you are correct. And the cwd for when the shell script is executed will be ~/.local/share/nvim/lspinstall/ruby

kabouzeid avatar Jul 15 '21 19:07 kabouzeid

Some evidence I've gathered:

  1. Running :LspInstall ruby outside of a directory containing a Gemfile works as expected
  2. pwd is always as expected
  3. bundle install seems to be running the context of the editor's cwd, and not the solargraph dir. This happens even if you change the command to something like cd solargraph && bundle install...

jherdman avatar Jul 16 '21 17:07 jherdman