fix BUILD_SANDBOX env var for updating sandbox while running linked binary (#729)

This commit is contained in:
Olcan 2025-06-03 14:02:00 -07:00 committed by GitHub
parent 9df94103ac
commit 12059eb4ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 5 deletions

View File

@ -269,19 +269,19 @@ export async function start_sandbox(sandbox: string) {
console.error(`hopping into sandbox (command: ${sandbox}) ...`); 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 gcPath = execSync(`realpath $(which gemini)`).toString().trim();
const image = await getSandboxImageName(); const image = await getSandboxImageName();
const workdir = process.cwd(); const workdir = process.cwd();
// if BUILD_SANDBOX is set, then call scripts/build_sandbox.sh under 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-code repo // note this can only be done with binary linked from gemini-cli repo
if (process.env.BUILD_SANDBOX) { if (process.env.BUILD_SANDBOX) {
if (!gcPath.includes('gemini-code/packages/')) { if (!gcPath.includes('gemini-cli/packages/')) {
console.error( console.error(
'ERROR: cannot BUILD_SANDBOX using installed gemini binary; ' + '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); process.exit(1);
} else { } else {
@ -300,6 +300,10 @@ export async function start_sandbox(sandbox: string) {
spawnSync(`cd ${gcRoot} && scripts/build_sandbox.sh ${buildArgs}`, { spawnSync(`cd ${gcRoot} && scripts/build_sandbox.sh ${buildArgs}`, {
stdio: 'inherit', stdio: 'inherit',
shell: true, shell: true,
env: {
...process.env,
GEMINI_SANDBOX: sandbox, // in case sandbox is enabled via flags (see config.ts under cli package)
},
}); });
} }
} }