fix(ruby): Normalize Ruby command PWD to the worktree root#288
fix(ruby): Normalize Ruby command PWD to the worktree root#288vitallium wants to merge 2 commits into
Conversation
This change makes Ruby-related commands run with a consistent PWD derived from the current worktree root. It adds a shared environment helper and uses it when: - invoking Bundler - resolving Ruby language server binaries - launching language servers from configured binaries, PATH, and the extension gemset Why: - Zed does not guarantee commands run from the project root - Ruby version managers like asdf and mise rely on PWD to detect the correct project Ruby - without this normalization, Bundler and language servers can resolve the wrong Ruby or gem context This is a hack, yes. And I am sorry about that.
The previous PWD-based attempt did not change the child process working directory, so Bundler and RubyGems could still resolve the wrong Ruby. Run extension-side bundle/ruby/gem probes through a worktree-root shell wrapper instead, and allow that wrapper in the manifest so fallback installation uses the same project context as the final language server.
7177e2e to
d11bc41
Compare
| [[capabilities]] | ||
| kind = "process:exec" | ||
| command = "sh" | ||
| args = ["-c", "*"] |
There was a problem hiding this comment.
@MrSubidubi Just checking-in, after zed-industries/zed#52249 was closed, the Ruby extensions is a bit broken due to that. I found this solution to the problem described in the PR.
- Since this extension must run some Ruby setup commands (bundle/ruby/gem) from the
worktree root so version managers like mise/asdf resolve the project Ruby
correctly. - AND The Zed extension process API does not expose a way to set the child process working directory
So I wonder if we can use sh -c as a minimal
cwd wrapper around those commands. I understand that sh -c * is quite broad pattern so I would like to hear your thoughts! Thanks!
There was a problem hiding this comment.
Yeah definitely broad but I see why you need this. I'd still prefer if we could look into the underlying issue first before proceeding here.
If we were to proceed here, I do think I'd prefer if we could make the arguments to the execute method an enum so that the API is a bit more limited than it currently is (e.g. RubyCommand::CheckGemBundle(args) (I am aware this might be a very bad example but my context here is limited) and then match on the command variants in the execute method)
This change makes Ruby-related commands run with a consistent PWD derived from the current worktree root. It adds a shared environment helper and uses it when:
This is a hack, yes. And I am sorry about that.