From ea0d006a6325c41979577b3bcfded9a1bc4c7791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=98=AF?= Date: Thu, 8 Oct 2026 13:47:19 +0800 Subject: [PATCH] scripts/try.sh: the sandbox gets a USERPROFILE on Windows, where that is the home (#44) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit try.sh runs magpie with env -i and a HOME pointing into the sandbox, so the real magpie, its agents and its sign-ins are never touched. On Windows that is no sandbox: magpie's home comes from USERPROFILE (appdir.homeVar) and HOME is not read, so env -i leaves USERPROFILE unset and magpie found no home at all — it stopped before doing anything with "USERPROFILE is not set: magpie needs the home folder to find its own files and the agents'", and scripts/try.sh was unusable on Windows. The sandbox is given USERPROFILE="$sb" beside HOME, which is a no-op elsewhere. A portable magpie.exe ignores both and can't be sandboxed this way, which predates this. --- scripts/try.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/try.sh b/scripts/try.sh index 494b0bd..60e0663 100755 --- a/scripts/try.sh +++ b/scripts/try.sh @@ -6,13 +6,21 @@ # scripts/try.sh grok login grok # then sign in # scripts/try.sh grok provider test grok # one tiny request per API # MAGPIE is the magpie binary (default: magpie on PATH). +# +# The sandbox is given HOME, and USERPROFILE too: on Windows magpie's +# home comes from USERPROFILE (appdir.homeVar) and HOME is not read, so +# with `env -i` giving only HOME, USERPROFILE is unset — magpie found no +# home at all and stopped before doing anything, with "USERPROFILE is not +# set: magpie needs the home folder to find its own files and the +# agents'". A portable magpie.exe is an exception: it ignores both and +# cannot be sandboxed this way. set -eu name=$1; shift root=$(cd "$(dirname "$0")/.." && pwd) sb=$root/.sandbox/$name mkdir -p "$sb" m=${MAGPIE:-magpie} -run() { env -i PATH="$PATH" HOME="$sb" XDG_CONFIG_HOME="$sb/.config" XDG_CACHE_HOME="$sb/.cache" "$m" "$@"; } +run() { env -i PATH="$PATH" HOME="$sb" USERPROFILE="$sb" XDG_CONFIG_HOME="$sb/.config" XDG_CACHE_HOME="$sb/.cache" "$m" "$@"; } if [ ! -f "$sb/.added" ]; then run plugin add "$root/packages/$name"