fix(local): respect configured cwd in init_session() (salvage #12983)#14242
Merged
Conversation
LocalEnvironment._run_bash() spawned subprocess.Popen without a cwd argument, so init_session()'s pwd -P ran in the gateway process's startup directory and overwrote self.cwd. Pass cwd=self.cwd so the initial snapshot captures the user-configured working directory. Tested: - pytest tests/ -q (255 env-related tests passed) - Full suite: 13,537 passed; 70 pre-existing failures unrelated to local env
13 tasks
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.
Salvages #12983 by @WuTianyi123 onto current main.
LocalEnvironment._run_bashbuilds asubprocess.Popenwithout passingcwd, so every bash invocation — including the initialinit_sessionbootstrap — inherits the Python process's current directory instead of the caller-configuredself.cwd. For regular commands this is masked by the_wrap_commandprefix (builtin cd $cwd ...), butinit_sessionbootstrap runs a rawpwd -P > cwd_filewithout a wrapping cd — it records the wrong starting directory.One-line fix: pass
cwd=self.cwdto Popen.self.cwdis always set (__init__defaults toos.getcwd()when no value provided), so no regression risk for callers that don't configure an explicit cwd.Attribution note
Original commit's author email was an unlinked Gmail address, so the commit was re-authored to @WuTianyi123's GitHub noreply email so the contribution attributes to their profile. All code is @WuTianyi123's.
Closes #12983.