Repository navigation
Translate PWD for WSL-launched Windows agents - #7111
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the WSL command launching logic to inject the current working directory (PWD) into the environment when WSL environment bridging is active, and updates the corresponding tests to verify this behavior. The reviewer suggested optimizing this change by directly appending "PWD/p" to wsl_env_bridge instead of redundantly re-running _wsl_bridge_names, and recommended moving this logic earlier to ensure consistency with the --no-launch execution path.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if wsl_env_bridge: | ||
| env = {**env, "PWD": os.getcwd()} | ||
| wsl_env_bridge = _wsl_bridge_names(env, unset_env) |
There was a problem hiding this comment.
Re-running _wsl_bridge_names(env, unset_env) is redundant and inefficient since we already know that PWD is a path and will be translated with the /p suffix (i.e., PWD/p). We can simply append "PWD/p" to the existing wsl_env_bridge tuple, which avoids iterating over the entire environment dictionary again.
Additionally, please note that the --no-launch path in _run (which prints the environment for copy-pasting) currently does not update env with PWD or bridge it. To ensure consistency between the direct launch and --no-launch copy-paste behaviors, you might want to apply this PWD injection logic in _run before the if not launch: check so both paths benefit from it.
| if wsl_env_bridge: | |
| env = {**env, "PWD": os.getcwd()} | |
| wsl_env_bridge = _wsl_bridge_names(env, unset_env) | |
| if wsl_env_bridge: | |
| env = {**env, "PWD": os.getcwd()} | |
| wsl_env_bridge = (*wsl_env_bridge, "PWD/p") |
There was a problem hiding this comment.
Addressed in c725796. _wsl_shim_env now computes the bridge once and is called only on the no-launch path, and the PWD override is applied on the launch path in _launch, so the redundant second computation is gone and the printed recipe is no longer frozen to the generation-time directory.
When a Windows npm shim is launched from WSL, route PWD through the existing WSLENV /p bridge so the Windows child process receives the cwd used by the wrapper instead of a stale inherited Linux PWD. Apply the same environment preparation to both direct launches and --no-launch copy-paste recipes, so printed commands behave like launched sessions. Add regression coverage for a WSL-launched Windows shim with a deliberately stale inherited PWD.
86230fe to
f454f18
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 15d85a4553
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| click.clear() | ||
| typer.echo(f"Studio {base} · model {entry['id']}") | ||
| wsl_env_bridge = _wsl_bridge_names(env, unset_env) if _wsl_windows_executable(command) else () | ||
| env, wsl_env_bridge = _wsl_shim_env(command, env, unset_env) |
There was a problem hiding this comment.
Don't freeze PWD in no-launch recipes
When --no-launch is used in WSL with a Windows shim, this call now injects a literal PWD=os.getcwd() before the print branch, and _print_env emits it as both an export and an inline assignment. If the printed recipe is run later from a different repository or by a driver that changes directories, the Windows agent gets a translated PWD for the old generation directory while its actual cwd is the new directory, so project-root discovery can target the wrong tree. The launch path needs the Python process cwd override, but the no-launch recipe should leave PWD to the shell at execution time while still adding PWD/p to WSLENV.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in c725796. The no-launch recipe now only adds PWD/p to WSLENV and no longer emits a literal export PWD, so it translates the shell's live PWD at execution time; the concrete cwd override stays on the direct-launch path in _launch.
Only add PWD/p to WSLENV in the no-launch path so the printed recipe translates the shell's live PWD when it is run, instead of pinning the generation-time directory. Apply the concrete cwd override only for a direct launch, which also removes the redundant second bridge computation.
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Resolve the _run echo conflict: keep main's Unsloth rename and drop the unconditional WSL bridge line, which now lives in the no-launch branch.
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
danielhanchen
left a comment
There was a problem hiding this comment.
Reviewed: bridges PWD via WSLENV for WSL-launched Windows shims without freezing it in no-launch recipes; concrete cwd override only on direct launch.
Bridge PWD through WSLENV /p when launching a Windows npm shim from WSL so project-root discovery uses the live cwd. The no-launch recipe adds PWD/p without freezing PWD; the concrete cwd override applies only on direct launch.
Summary
Why
If an agent was installed on Windows first, WSL may resolve the Windows npm shim under /mnt/c. In that case the wrapper already uses WSLENV to translate path-valued environment variables for the Windows child process. PWD should follow the same path: otherwise a stale inherited Linux PWD can affect project-root discovery in the Windows-launched agent.
Verification