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
7 changes: 7 additions & 0 deletions containers/agent/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,13 @@ AWFEOF
echo "export PATH=\"${AWF_GOROOT}/bin:\$PATH\"" >> "/host${SCRIPT_FILE}"
echo "export GOROOT=\"${AWF_GOROOT}\"" >> "/host${SCRIPT_FILE}"
fi
# Add BUN_INSTALL/bin to PATH if provided (for Bun on GitHub Actions)
# Bun must be pre-installed on the host because it crashes inside chroot (restricted /proc)
if [ -n "${AWF_BUN_INSTALL}" ]; then
echo "[entrypoint] Adding BUN_INSTALL/bin to PATH: ${AWF_BUN_INSTALL}/bin"
echo "export PATH=\"${AWF_BUN_INSTALL}/bin:\$PATH\"" >> "/host${SCRIPT_FILE}"
echo "export BUN_INSTALL=\"${AWF_BUN_INSTALL}\"" >> "/host${SCRIPT_FILE}"
fi
else
echo "[entrypoint] Constructing default PATH for chroot"
cat > "/host${SCRIPT_FILE}" << 'AWFEOF'
Expand Down
31 changes: 30 additions & 1 deletion src/docker-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,14 +623,16 @@ describe('docker-manager', () => {
expect(environment.AWF_CHROOT_ENABLED).toBe('true');
});

it('should pass GOROOT, CARGO_HOME, JAVA_HOME to container when enableChroot is true and env vars are set', () => {
it('should pass GOROOT, CARGO_HOME, JAVA_HOME, BUN_INSTALL to container when enableChroot is true and env vars are set', () => {
const originalGoroot = process.env.GOROOT;
const originalCargoHome = process.env.CARGO_HOME;
const originalJavaHome = process.env.JAVA_HOME;
const originalBunInstall = process.env.BUN_INSTALL;

process.env.GOROOT = '/usr/local/go';
process.env.CARGO_HOME = '/home/user/.cargo';
process.env.JAVA_HOME = '/usr/lib/jvm/java-17';
process.env.BUN_INSTALL = '/home/user/.bun';

try {
const configWithChroot = {
Expand All @@ -644,6 +646,7 @@ describe('docker-manager', () => {
expect(environment.AWF_GOROOT).toBe('/usr/local/go');
expect(environment.AWF_CARGO_HOME).toBe('/home/user/.cargo');
expect(environment.AWF_JAVA_HOME).toBe('/usr/lib/jvm/java-17');
expect(environment.AWF_BUN_INSTALL).toBe('/home/user/.bun');
} finally {
// Restore original values
if (originalGoroot !== undefined) {
Expand All @@ -661,6 +664,32 @@ describe('docker-manager', () => {
} else {
delete process.env.JAVA_HOME;
}
if (originalBunInstall !== undefined) {
process.env.BUN_INSTALL = originalBunInstall;
} else {
delete process.env.BUN_INSTALL;
}
}
});

it('should NOT set AWF_BUN_INSTALL when BUN_INSTALL is not in environment', () => {
const originalBunInstall = process.env.BUN_INSTALL;
delete process.env.BUN_INSTALL;

try {
const configWithChroot = {
...mockConfig,
enableChroot: true
};
const result = generateDockerCompose(configWithChroot, mockNetworkConfig);
const agent = result.services.agent;
const environment = agent.environment as Record<string, string>;

expect(environment.AWF_BUN_INSTALL).toBeUndefined();
} finally {
if (originalBunInstall !== undefined) {
process.env.BUN_INSTALL = originalBunInstall;
}
}
});

Expand Down
6 changes: 6 additions & 0 deletions src/docker-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,12 @@ export function generateDockerCompose(
if (process.env.JAVA_HOME) {
environment.AWF_JAVA_HOME = process.env.JAVA_HOME;
}
// Bun: Pass BUN_INSTALL so entrypoint can add $BUN_INSTALL/bin to PATH
// Bun crashes with core dump when installed inside chroot (restricted /proc access),
// so it must be pre-installed on the host via setup-bun action
Comment on lines +356 to +358
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding documentation for BUN_INSTALL similar to the GOROOT section in docs/chroot-mode.md. Since Bun has special requirements (crashes inside chroot due to restricted /proc access), users would benefit from documentation showing how to properly set up Bun in GitHub Actions workflows with chroot mode, similar to the existing GOROOT documentation at lines 114-133 in docs/chroot-mode.md.

Suggested change
// Bun: Pass BUN_INSTALL so entrypoint can add $BUN_INSTALL/bin to PATH
// Bun crashes with core dump when installed inside chroot (restricted /proc access),
// so it must be pre-installed on the host via setup-bun action
// Bun:
// - Bun crashes with a core dump when installed inside the chroot (restricted /proc access).
// - Bun must therefore be installed on the host (e.g. via oven-sh/setup-bun in a GitHub Actions
// workflow), which sets BUN_INSTALL to the host install directory.
// - We pass BUN_INSTALL through as AWF_BUN_INSTALL so entrypoint.sh can, in the chroot script,
// add "$BUN_INSTALL/bin" to PATH and make the host-installed Bun available inside the chroot.

Copilot uses AI. Check for mistakes.
if (process.env.BUN_INSTALL) {
environment.AWF_BUN_INSTALL = process.env.BUN_INSTALL;
}
}

// If --env-all is specified, pass through all host environment variables (except excluded ones)
Expand Down
Loading