-
Notifications
You must be signed in to change notification settings - Fork 172
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
Rely always on workspace URI instead of Dir.pwd #2424
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the workspace_path
is the key information for the indexer and now requires external output, we should make it a required argument and change how RubyIndexer::Configuration
is initialized, even if we simply pass Dir.pwd
in the first and change it later.
Since an Index's data is scoped by configuration, we should make the configuration part of the index. This is especially true with #2424 coming because changing the state of `RubyIndexer.configuration` to affect the index is surprising.
Since an Index's data is scoped by configuration, we should make the configuration part of the index. This is especially true with #2424 coming because changing the state of `RubyIndexer.configuration` to affect the index is surprising.
I opened #2433 to change the way configuration is initialized. |
Since an Index's data is scoped by configuration, we should make the configuration part of the index. This is especially true with #2424 coming because changing the state of `RubyIndexer.configuration` to affect the index is surprising.
a84055c
to
0f83a1a
Compare
c678b0b
to
766621d
Compare
f0f359b
to
6a701ea
Compare
Motivation
Closes #2382
This PR stops using
Dir.pwd
and starts relying exclusively on the workspace URI provided by the client.Dir.pwd
is not adequate because clients may spawn the language server in a directory that isn't the workspace. In addition to that,Dir.pwd
may be a symlink, which can also cause issues in certain situations (as we received reports in the past).Important note
There's one major caveat here. We are still unable to get rid of this usage of Dir.pwd when setting up the custom bundle.
The reason is because the way Bundler works is a bit incompatible with how language servers work and that prevents us from doing the right thing here. What the LSP spec dictates is that a language server should spawn and immediately respond to the
initialize
request.However, for user convenience, we first setup the custom bundle, so that people don't have to add
ruby-lsp
to their Gemfiles. Ideally, we wouldBundler.setup
to organize the load paths as necessaryBundler doesn't allow you to invoke
Bundler.setup
twice. And even if we only invoke it once, we would not be able to require anything until theBundler.setup
call happens because that may lead to required gem version mismatches.This is the reason why we setup the custom bundle and then replace the existing process with a bundle exec version of it.
Because of the process replacement thing, we cannot read the
initialize
request from STDIN while setting up the custom bundle or else the parameters for initialization would be completely lost after re-launching the process with bundle exec.Finally, since we cannot read the request parameters during custom bundle initialization, we do not know what the workspace URI is.
My hope is to work more closely with the Bundler team and brainstorm some way that dependency setup can be better integrated into the way language servers work. That would not only improve the
Dir.pwd
thing, but it would allow us to display custom error messages depending on which failures happened during the custom bundle setup. For now, this is the best we can do.Implementation
Started using the provided workspace URI everywhere and removed all
Dir.pwd
usages that aren't in tests.Automated Tests
Adapted existing tests.