kabouzeid / nvim-lspinstall

Provides the missing :LspInstall for nvim-lspconfig
MIT License
526 stars 67 forks source link

Ruby (Solargraph) Install Modifies Local Bundle Config #120

Open jherdman opened 3 years ago

jherdman commented 3 years ago

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.

kabouzeid commented 3 years ago

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

jherdman commented 3 years ago

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.

kabouzeid commented 3 years ago

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 :)

jherdman commented 3 years ago

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

kabouzeid commented 3 years ago

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

jherdman commented 3 years ago

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...