Skip to content

Commit d22c053

Browse files
committed
Fix runner hook execution by inheriting system environment
The GitHub Actions runner was failing to execute job hooks with 'sh: command not found' error. This was because the runner process was started with only RUNNER_ALLOW_RUNASROOT in its environment, missing PATH and other system variables needed to locate and execute shell commands. Fixed by inheriting the system environment when starting the runner process, ensuring PATH and other critical environment variables are available.
1 parent 32c9080 commit d22c053

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/ec2_gha/templates/user-script.sh.templ

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,11 @@ for config in configs:
437437
438438
# Start runner in background (use full path and handle errors)
439439
try:
440+
# Inherit system environment and add RUNNER_ALLOW_RUNASROOT
441+
runner_env = os.environ.copy()
442+
runner_env['RUNNER_ALLOW_RUNASROOT'] = '1'
440443
proc = subprocess.Popen([f'{runner_dir}/run.sh'],
441-
env={'RUNNER_ALLOW_RUNASROOT': '1'},
444+
env=runner_env,
442445
cwd=runner_dir,
443446
stdout=subprocess.DEVNULL,
444447
stderr=subprocess.DEVNULL)

0 commit comments

Comments
 (0)