Windows: AppContainer sandbox breaks when git on PATH is a shim (Scoop) #92
Labels
No labels
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
priority
critical
priority
high
priority
low
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Beanstalk#92
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Symptom
On a Windows 11 tester machine with Git installed via Scoop,
scripts/dev_packs.py basefails inside the AppContainer sandbox when invokinggit:Root cause (and why #62's
MinGitfallback doesn't trigger)gitonPATHresolves toC:\Users\<user>\scoop\shims\git.exe, paired withgit.shim:Workspace.EnsureGitAsync(agent/Core/Workspace.cs, added in #62) only downloadsMinGitwhenMinGit.OnPath(PATH)returnsnull. BecauseMinGit.OnPath(agent/Core/MinGit.cs) only checksFile.Exists(Path.Combine(dir, "git.exe")), it seesC:\Users\<user>\scoop\shims\git.exe, returns non-null, and skipsMinGit.WinHost.Git()(agent/Core/WindowsSandbox.cs) also stops at the firstgit.exeonPATH(C:\Users\<user>\scoop\shims\git.exe), only strips\cmdor\bin(not\shims), grants the AppContainer read/execute access only toC:\Users\<user>\scoop\shims, and putsC:\Users\<user>\scoop\shimson the sandboxPATH.git.exeshim tries to launchC:\Users\<user>\scoop\apps\git\current\cmd\git.exe(which is outside the granted folders), fails, and exits with status1. (safe.directoryis already handled byWinEnvviaGIT_CONFIG_COUNT=1.)The same failure pattern applies to any package-manager shim on
PATHwhose target binary lives outside the shim directory (such as Scoop.shimstubs or Chocolatey shims).Proposed fix & scope
git.exeonPATH(agent/Core/MinGit.cs,agent/Core/WindowsSandbox.cs):PATHlookup betweenMinGit.OnPathandWinHost.Git()so shim executables are skipped (e.g., when a siblinggit.shimexists for Scoop, or a shim directory/stub such as Chocolatey'schocolatey\bin).PATHso a realgit.exelater onPATH(such asC:\Program Files\Git\cmd\git.exe) is still used if present.git.exeexists onPATH, returnnullfromOnPathsoWorkspace.EnsureGitAsyncfetches and uses Beanstalk's ownMinGit(<data>\mingit\cmd\git.exe), which runs off theY:work drive inside the AppContainer. (Falling back toMinGitavoids NTFS junction issues with Scoop'scurrentlink and%USERPROFILE%traversal issues that grantingscoop\apps\gitdirectly would risk.)agent/tests/agent_core/SetupChecks.cs):git.shim(both falling back to a laterPATHentry and returningnullto triggerMinGit).git --versioninside the Windows sandbox self-test (WinSandbox) so an unusablegit.exeonPATHfails visibly at Setup instead of mid-job insidedev_packs.py.(Separate repo note: in Longshot's
scripts/dev_packs.py,git()usescapture_output=True, soCalledProcessErrorcurrently hidesstderr.)Workaround
Uninstalling Scoop's
git(scoop uninstall git) so Beanstalk falls back toMinGit, or installing standard Git for Windows intoC:\Program Files\Git(withC:\Program Files\Git\cmdahead of any shims), resolves the failure.Possibly related, for context: