fix(sandbox): pass VSCODE_CWD env var to preserve workspace CWD in sandbox#315538
Open
yehsuf wants to merge 5 commits into
Open
fix(sandbox): pass VSCODE_CWD env var to preserve workspace CWD in sandbox#315538yehsuf wants to merge 5 commits into
yehsuf wants to merge 5 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes sandboxed terminal commands using the wrong working directory by ensuring the sandbox runtime preserves the original workspace CWD via VSCODE_CWD, rather than letting bootstrap-node.ts default it to the sandbox temp directory.
Changes:
- Pass
VSCODE_CWD=<actual cwd>as an environment variable when launching the sandbox runtime. - Keep existing Linux behavior of launching the sandbox runtime from the temp dir while restoring the original CWD for the user command.
…ndbox When the sandbox wraps a terminal command on Linux, it cd's into tempDir before launching the sandbox runtime. bootstrap-node.ts then sets VSCODE_CWD=process.cwd() (the tempDir) if the env var is unset, causing all sandboxed commands to run in tempDir instead of the workspace root. Fix: pass VSCODE_CWD=<actual cwd> as an environment variable in the sandbox runtime command, so bootstrap-node.ts preserves the correct working directory. Includes unit test verifying VSCODE_CWD presence/absence based on cwd. Fixes microsoft#313938
d2afc9a to
4343b37
Compare
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
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.
Fixes #313938
When the sandbox wraps a terminal command on Linux, it cd's into tempDir before launching the sandbox runtime. bootstrap-node.ts then sets VSCODE_CWD=process.cwd() (the tempDir) if the env var is unset, causing all sandboxed commands to run in tempDir instead of the workspace root.
Fix: pass VSCODE_CWD= as an environment variable in the sandbox runtime command, so bootstrap-node.ts preserves the correct working directory.