Closed alexpls closed 2 months ago
Thank you for the bug report! This is indeed a bug, which is reported in #336. We're looking into fixing, but thank you for offering the contribution!
I'll close this issue to keep discussions centralized in the other one.
Thanks! I'll keep an eye on #336.
When
ruby-lsp-rails
spawns the Rails instance usingrails runner
, it passes on the bundler context of theruby-lsp
bundle instead of the application bundle.This leads to issues when application code references
Bundler.root
orBUNDLE_GEMFILE
expecting to get a path to the application root, but instead gets a path to the.ruby-lsp
dir.For a minimal repro, you can try this:
Running
rails s
will start the application just fine, however opening the app's dir in an editor withruby-lsp
configured will lead to theruby-lsp-rails
failing to initialize the server with this error:In my case, I've monkey-patched
runner_client.rb
to setENV['BUNDLE_GEMFILE']
to my app's Gemfile and have verified that after that, things work fine.If you agree this is an issue that should be addressed and I'm not doing anything silly, I can look at opening a PR implementing a proper fix.
(versions:
ruby-lsp-rails
0.3.5,ruby-lsp
0.16.4)