feat(BREV-2866): open shell in expected container working directory#308
Open
nisolanki1209 wants to merge 2 commits intomainfrom
Open
feat(BREV-2866): open shell in expected container working directory#308nisolanki1209 wants to merge 2 commits intomainfrom
nisolanki1209 wants to merge 2 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the brev shell command to respect the container's WORKDIR when opening an interactive shell session in a custom container. Previously, users were placed in the default SSH login directory (/root) regardless of the container's intended working directory.
Changes:
- The
runSSHfunction signature is updated to accept ahost boolparameter, and the call site is updated accordingly. - When
host=false(the container path), the SSH command now reads/proc/1/cwdviareadlink(withpwdas a fallback) to determine the container's working directory, thencds into it before executing the shell. - The
host=truepath retains the original simplesshcommand behavior without modifications.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f2209a4 to
a4dc1d9
Compare
drewmalin
approved these changes
Mar 17, 2026
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.
Problem
When launching a custom container, brev shell did not take the container’s
WORKDIRinto account. It opened a standard shell session, which defaults to the root user’s home directory, instead of the container’sWORKDIR.As a result, users were placed in
/rootrather than the container’s intendedWORKDIR.Solution
Updated the runSSH function to detect and respect the container’s
WORKDIRwhen launching brev shell.WORKDIRby reading/proc/1/cwd(PID 1 working directory).pwdif/proc/1/cwdis unavailable.${SHELL}with/bin/shas a fallback for minimal containers.