From 12059eb4cac7e37f4256649097b4f9f23df8eb4c Mon Sep 17 00:00:00 2001 From: Olcan Date: Tue, 3 Jun 2025 14:02:00 -0700 Subject: [PATCH] fix BUILD_SANDBOX env var for updating sandbox while running linked binary (#729) --- packages/cli/src/utils/sandbox.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/cli/src/utils/sandbox.ts b/packages/cli/src/utils/sandbox.ts index b41dccf5..1f8e74c9 100644 --- a/packages/cli/src/utils/sandbox.ts +++ b/packages/cli/src/utils/sandbox.ts @@ -269,19 +269,19 @@ export async function start_sandbox(sandbox: string) { console.error(`hopping into sandbox (command: ${sandbox}) ...`); - // determine full path for gemini-code to distinguish linked vs installed setting + // determine full path for gemini-cli to distinguish linked vs installed setting const gcPath = execSync(`realpath $(which gemini)`).toString().trim(); const image = await getSandboxImageName(); const workdir = process.cwd(); - // if BUILD_SANDBOX is set, then call scripts/build_sandbox.sh under gemini-code repo - // note this can only be done with binary linked from gemini-code repo + // if BUILD_SANDBOX is set, then call scripts/build_sandbox.sh under gemini-cli repo + // note this can only be done with binary linked from gemini-cli repo if (process.env.BUILD_SANDBOX) { - if (!gcPath.includes('gemini-code/packages/')) { + if (!gcPath.includes('gemini-cli/packages/')) { console.error( 'ERROR: cannot BUILD_SANDBOX using installed gemini binary; ' + - 'run `npm link ./packages/cli` under gemini-code repo to switch to linked binary.', + 'run `npm link ./packages/cli` under gemini-cli repo to switch to linked binary.', ); process.exit(1); } else { @@ -300,6 +300,10 @@ export async function start_sandbox(sandbox: string) { spawnSync(`cd ${gcRoot} && scripts/build_sandbox.sh ${buildArgs}`, { stdio: 'inherit', shell: true, + env: { + ...process.env, + GEMINI_SANDBOX: sandbox, // in case sandbox is enabled via flags (see config.ts under cli package) + }, }); } }