Skip to content

fix(ruby): Normalize Ruby command PWD to the worktree root#288

Open
vitallium wants to merge 2 commits into
mainfrom
vs/cwd-workaround
Open

fix(ruby): Normalize Ruby command PWD to the worktree root#288
vitallium wants to merge 2 commits into
mainfrom
vs/cwd-workaround

Conversation

@vitallium
Copy link
Copy Markdown
Collaborator

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.

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.
@cla-bot cla-bot Bot added the cla-signed label May 11, 2026
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.
@vitallium vitallium force-pushed the vs/cwd-workaround branch from 7177e2e to d11bc41 Compare May 11, 2026 19:11
Comment thread extension.toml
Comment on lines +92 to +95
[[capabilities]]
kind = "process:exec"
command = "sh"
args = ["-c", "*"]
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant