-
Notifications
You must be signed in to change notification settings - Fork 11
Use new process API for starting language servers #48
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
Draft
vitallium
wants to merge
3
commits into
main
Choose a base branch
from
vs/process-api-impl
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a054c77
to
43a4731
Compare
43a4731
to
a1a44a3
Compare
a1a44a3
to
13ed19e
Compare
SomeoneToIgnore
pushed a commit
to zed-industries/zed
that referenced
this pull request
Apr 9, 2025
…28173) ## Description In #27213 the new feature for setting env variables for LSPs was added but env vars passed from an instance of `ExtensionLspAdapter` are lost now. This means if an extension returns any env variable like this: ```rust zed::Command { command: some_command, args: some_args, env: vec![("A", "value_for_a")], } ``` The env variable `A` will never be used by `LspStore`. This commit preserves env variables passed from an instance of `ExtensionLspAdapter`. After this change overwriting of env variables happens in the following order: ```plaintext shell <- variables from an extension <- variables from settings ``` ## How to reproduce Allow any extension to return a `zed::Command` with environment variables to Zed. You can use [this branch](zed-extensions/ruby#48) for the Ruby extension: 1. Check out the branch and install the dev version of the Ruby extension. 2. Ensure you have the `solargraph` LSP configured and enabled for the Ruby extension. This LSP is enabled by default in Zed and in the Ruby extension. 3. Make sure you don’t have `solargraph` installed in your user gemset. 4. Open any Ruby project, such as [this one](https://github.com/vitallium/stimulus-lsp-error-zed). 5. Open a Ruby file and wait for the error message about failing to start `solargraph`. It should look like this or something similar: ``` [2025-04-05T23:17:26+02:00 ERROR project::lsp_store] server stderr: "/Users/vslobodin/.local/share/mise/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:262:in 'Gem.find_spec_for_exe': can't find gem solargraph (>= 0.a) with executable solargraph (Gem::GemNotFoundException)\n\tfrom /Users/vslobodin/.local/share/mise/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:281:in 'Gem.activate_bin_path'\n" ``` This error occurs because the Ruby extension passes the `GEM_PATH` environment variable to specify the location of Ruby gems. Without it, Zed tries to spawn the `solargraph` gem in the user's gemset scope. Ruby fails to start it because the `solargraph` gem is not installed in the user gemset but in the extension directory. By setting the `GEM_PATH` environment variable, Ruby searches additional locations to start the `solargraph` LSP. I hope I've described it correctly. Please let me know if you need more information. Thanks! Release Notes: - Fixed the issue where environment variables from `ExtensionLspAdapter` were lost
excited about this =-) thanks for working on it |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Use new process API for starting language servers
Improve initial developer experience of the Ruby extension by utilizing the new
Process
API for starting language servers.Key points:
binary.path
option acts as a circuit breaker in the activation logic for experienced users and for debugging purposes.Test cases
All test cases and current activation logic:
lsp.<LSP_NAME>.binary.path
is available, ignore theuse_bundler
configuration option value and use the provided path.use_bundler
configuration option is true:bundle exec
. In most cases, this will activate the version available in the project's gemset.use_bundler
configuration option is false:solargraph (default)
solargraph
Demo
Using
solargraph
from the project' gemset:solargraph_extension_gemset.mp4
Using
solargraph
from the extenion' gemset:solargraph_project_gemset.mp4
ruby-lsp
ruby-lsp
rubocop
rubocop
TODO
Resources