From 79e878fbf4a18624d5e666b342c16f869011a55a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Tue, 1 Dec 2026 01:41:00 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20a=20runner=20host=20witho?= =?UTF-8?q?ut=20git=20fails=20the=20job=20with=20"git=20is=20not=20install?= =?UTF-8?q?ed=20on=20the=20runner=20host"=20instead=20of=20a=20bare=20"No?= =?UTF-8?q?=20such=20file=20or=20directory",=20and=20forge=20runner=20chec?= =?UTF-8?q?k=20tests=20for=20git;=20=F0=9F=93=9D=20docs:=20git=20is=20a=20?= =?UTF-8?q?runner=20host=20requirement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/forge-runner/src/check.rs | 14 +++++++++++++- crates/forge-runner/src/workspace.rs | 8 +++++++- docs/ci.md | 1 + 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/crates/forge-runner/src/check.rs b/crates/forge-runner/src/check.rs index 56f516f..956184d 100644 --- a/crates/forge-runner/src/check.rs +++ b/crates/forge-runner/src/check.rs @@ -231,6 +231,18 @@ fn delegated_controllers() -> Result, String> { Ok(enabled.split_whitespace().map(str::to_owned).collect()) } +/// The runner checks out each job's commit with the host's `git`. +async fn git_line() -> Line { + match Command::new("git").arg("--version").output().await { + Ok(out) if out.status.success() => Line::ok( + "git", + String::from_utf8_lossy(&out.stdout).trim().to_owned(), + ), + Ok(out) => Line::fail("git", format!("git --version exited with {}", out.status)), + Err(e) => Line::fail("git", format!("git is not installed on this host: {e}")), + } +} + /// Builds the report from the probe result. Pure, so the rules can be tested. fn report(probe: Result<&Probe, &str>, controllers: Result<&[String], &str>) -> Vec { let mut lines = Vec::new(); @@ -410,7 +422,7 @@ pub async fn run(helper: &Path, work_dir: &Path, mode: UsernsMode) -> bool { }; let probe = run_probe(helper, &work_dir, &map).await; let controllers = delegated_controllers(); - let mut lines = vec![Line::ok("user ids", map.describe())]; + let mut lines = vec![Line::ok("user ids", map.describe()), git_line().await]; lines.extend(report( probe.as_ref().map_err(String::as_str), controllers.as_deref().map_err(String::as_str), diff --git a/crates/forge-runner/src/workspace.rs b/crates/forge-runner/src/workspace.rs index 331285c..b6c2152 100644 --- a/crates/forge-runner/src/workspace.rs +++ b/crates/forge-runner/src/workspace.rs @@ -170,7 +170,13 @@ async fn git( .stderr(Stdio::piped()) .kill_on_drop(true) .output() - .await?; + .await + .map_err(|e| match e.kind() { + std::io::ErrorKind::NotFound => { + WorkspaceError::Invalid("git is not installed on the runner host".to_owned()) + } + _ => WorkspaceError::Io(e), + })?; if output.status.success() { return Ok(()); } diff --git a/docs/ci.md b/docs/ci.md index 73c51f5..a0ab4af 100644 --- a/docs/ci.md +++ b/docs/ci.md @@ -487,6 +487,7 @@ but operators should use `forge runner`, which the examples below show. The builtin executor needs: +- **git** on the host. The runner checks out each job's commit with it. - **Linux 5.11 or newer.** Overlayfs inside a user namespace needs it. On an older kernel, jobs still run, but each one gets a full copy of the image instead of an overlay. - **Unprivileged user namespaces.** Check that `/proc/sys/user/max_user_namespaces` is above 0. On