refined sandbox/seatbelt log message, pass NODE_OPTIONS along to sandboxed node (#292)
This commit is contained in:
parent
3b025883b6
commit
b1c449d11c
|
@ -31,7 +31,6 @@ async function main() {
|
||||||
if (!process.env.SANDBOX) {
|
if (!process.env.SANDBOX) {
|
||||||
const sandbox = sandbox_command(config.getSandbox());
|
const sandbox = sandbox_command(config.getSandbox());
|
||||||
if (sandbox) {
|
if (sandbox) {
|
||||||
console.log('hopping into sandbox ...');
|
|
||||||
await start_sandbox(sandbox);
|
await start_sandbox(sandbox);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,7 +142,8 @@ function entrypoint(workdir: string): string[] {
|
||||||
|
|
||||||
export async function start_sandbox(sandbox: string) {
|
export async function start_sandbox(sandbox: string) {
|
||||||
if (sandbox === 'sandbox-exec') {
|
if (sandbox === 'sandbox-exec') {
|
||||||
process.env.SEATBELT_PROFILE ??= 'minimal';
|
const profile = (process.env.SEATBELT_PROFILE ??= 'minimal');
|
||||||
|
console.log(`using macos seatbelt (profile: ${profile}) ...`);
|
||||||
const args = [
|
const args = [
|
||||||
'-D',
|
'-D',
|
||||||
`TARGET_DIR=${fs.realpathSync(process.cwd())}`,
|
`TARGET_DIR=${fs.realpathSync(process.cwd())}`,
|
||||||
|
@ -151,19 +152,18 @@ export async function start_sandbox(sandbox: string) {
|
||||||
'-D',
|
'-D',
|
||||||
`HOME_DIR=${fs.realpathSync(os.homedir())}`,
|
`HOME_DIR=${fs.realpathSync(os.homedir())}`,
|
||||||
'-f',
|
'-f',
|
||||||
new URL(
|
new URL(`sandbox-macos-${profile}.sb`, import.meta.url).pathname,
|
||||||
`sandbox-macos-${process.env.SEATBELT_PROFILE}.sb`,
|
|
||||||
import.meta.url,
|
|
||||||
).pathname,
|
|
||||||
'bash',
|
'bash',
|
||||||
'-c',
|
'-c',
|
||||||
'SANDBOX=sandbox-exec ' +
|
`SANDBOX=sandbox-exec NODE_OPTIONS="${process.env.NODE_OPTIONS}" ` +
|
||||||
process.argv.map((arg) => quote([arg])).join(' '),
|
process.argv.map((arg) => quote([arg])).join(' '),
|
||||||
];
|
];
|
||||||
spawnSync(sandbox, args, { stdio: 'inherit' });
|
spawnSync(sandbox, args, { stdio: 'inherit' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(`hopping into sandbox (command: ${sandbox}) ...`);
|
||||||
|
|
||||||
// determine full path for gemini-code to distinguish linked vs installed setting
|
// determine full path for gemini-code to distinguish linked vs installed setting
|
||||||
const gcPath = execSync(`realpath $(which gemini-code)`).toString().trim();
|
const gcPath = execSync(`realpath $(which gemini-code)`).toString().trim();
|
||||||
|
|
||||||
|
@ -345,6 +345,11 @@ export async function start_sandbox(sandbox: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// copy NODE_OPTIONS
|
||||||
|
if (process.env.NODE_OPTIONS) {
|
||||||
|
args.push('--env', `NODE_OPTIONS="${process.env.NODE_OPTIONS}"`);
|
||||||
|
}
|
||||||
|
|
||||||
// set SANDBOX as container name
|
// set SANDBOX as container name
|
||||||
args.push('--env', `SANDBOX=${containerName}-${index}`);
|
args.push('--env', `SANDBOX=${containerName}-${index}`);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue