Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integration-tests/globalSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export async function setup() {

// Environment variables for CLI integration tests
process.env['INTEGRATION_TEST_FILE_DIR'] = runDir;
process.env['GEMINI_CLI_INTEGRATION_TEST'] = 'true';
process.env['QWEN_CODE_INTEGRATION_TEST'] = 'true';
process.env['TELEMETRY_LOG_FILE'] = join(runDir, 'telemetry.log');

// Environment variables for SDK E2E tests
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"build:vscode": "node scripts/build_vscode_companion.js",
"build:all": "npm run build && npm run build:sandbox && npm run build:vscode",
"build:packages": "npm run build --workspaces",
"build:sandbox": "node scripts/build_sandbox.js -s",
"build:sandbox": "node scripts/build_sandbox.js",
"bundle": "npm run generate && node esbuild.config.js && node scripts/copy_bundle_assets.js",
"test": "npm run test --workspaces --if-present --parallel",
"test:ci": "npm run test:ci --workspaces --if-present --parallel && npm run test:scripts",
Expand Down
20 changes: 12 additions & 8 deletions packages/cli/src/utils/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ export async function start_sandbox(
// name container after image, plus random suffix to avoid conflicts
const imageName = parseImageName(image);
const isIntegrationTest =
process.env['GEMINI_CLI_INTEGRATION_TEST'] === 'true';
process.env['QWEN_CODE_INTEGRATION_TEST'] === 'true';
let containerName;
if (isIntegrationTest) {
containerName = `qwen-code-integration-test-${randomBytes(4).toString(
Expand Down Expand Up @@ -721,11 +721,10 @@ export async function start_sandbox(
// tests that need to access host's ~/.qwen (e.g., --resume functionality)
const useCurrentUser = await shouldUseCurrentUserInSandbox();

if (!useCurrentUser) {
// Use root user (default for integration tests or when explicitly disabled)
args.push('--user', 'root');
userFlag = '--user root';
} else {
if (useCurrentUser) {
// SANDBOX_SET_UID_GID is enabled: create user with host's UID/GID
// This includes integration test mode with SANDBOX_SET_UID_GID=true,
// allowing tests that need to access host's ~/.qwen (e.g., --resume) to work.
// For the user-creation logic to work, the container must start as root.
// The entrypoint script then handles dropping privileges to the correct user.
args.push('--user', 'root');
Expand All @@ -735,10 +734,10 @@ export async function start_sandbox(

// Instead of passing --user to the main sandbox container, we let it
// start as root, then create a user with the host's UID/GID, and
// finally switch to that user to run the gemini process. This is
// finally switch to that user to run the qwen process. This is
// necessary on Linux to ensure the user exists within the
// container's /etc/passwd file, which is required by os.userInfo().
const username = 'gemini';
const username = 'qwen';
const homeDir = getContainerPath(os.homedir());

const setupUserCommands = [
Expand All @@ -761,7 +760,12 @@ export async function start_sandbox(
userFlag = `--user ${uid}:${gid}`;
// When forcing a UID in the sandbox, $HOME can be reset to '/', so we copy $HOME as well.
args.push('--env', `HOME=${os.homedir()}`);
} else if (isIntegrationTest) {
// Integration test mode with UID/GID matching disabled: use root
args.push('--user', 'root');
userFlag = '--user root';
}
// else: non-IT mode with UID/GID matching disabled - use image default user (node)

// push container image name
args.push(image);
Expand Down