From ccf421a9d8856d8d2b1b65072c7ba43c1ba8311d 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 05:13:51 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20Build's=20podman=20calls?= =?UTF-8?q?=20always=20talk=20to=20the=20systemd=20user=20bus=20(crun=20ne?= =?UTF-8?q?eds=20it=20for=20cgroups;=20a=20foreign=20DBUS=5FSESSION=5FBUS?= =?UTF-8?q?=5FADDRESS=20made=20container=20start=20fail),=20and=20a=20fail?= =?UTF-8?q?ed=20command=20reports=20its=20last=20stderr=20line=20instead?= =?UTF-8?q?=20of=20the=20first=20(pull=20progress=20hid=20the=20real=20err?= =?UTF-8?q?or)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/client/src/release.rs | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/crates/client/src/release.rs b/crates/client/src/release.rs index d9ada5a..91149bd 100644 --- a/crates/client/src/release.rs +++ b/crates/client/src/release.rs @@ -218,7 +218,7 @@ fn preflight(source: &Path) -> Result { } fn container_running(container: &str) -> bool { - Command::new("podman") + podman() .args(["inspect", "-f", "{{.State.Running}}", container]) .output() .is_ok_and(|out| String::from_utf8_lossy(&out.stdout).trim() == "true") @@ -308,7 +308,7 @@ fn host_rust() -> Result { } fn in_linux(script: &str) -> Command { - let mut cmd = Command::new("podman"); + let mut cmd = podman(); cmd.args(["exec", "-w", "/build"]) .args(["-e", "PATH=/root/.cargo/bin:/usr/local/bin:/usr/bin:/bin"]) .args(["-e", "DEBIAN_FRONTEND=noninteractive"]) @@ -329,7 +329,7 @@ fn start_linux(job: Job, source: &Path, cx: &Cx) -> Result<(), String> { cx.send(Event::Line(job, "creating container".into())); let mount = |dir: &str, at: &str| format!("{}:{at}:Z", cache.join(dir).display()); check( - Command::new("podman") + podman() .args(["run", "-d", "--name", LINUX]) .args(["-v", &mount("cargo", "/root/.cargo")]) .args(["-v", &mount("rustup", "/root/.rustup")]) @@ -337,10 +337,10 @@ fn start_linux(job: Job, source: &Path, cx: &Cx) -> Result<(), String> { .args([LINUX_IMAGE, "sleep", "infinity"]), )?; } else { - check(Command::new("podman").args(["start", LINUX]))?; + check(podman().args(["start", LINUX]))?; } check( - Command::new("podman") + podman() .arg("cp") .arg(source.join(ARCHIVE)) .arg(format!("{LINUX}:/build/src.tgz")), @@ -433,7 +433,7 @@ fn create_windows(job: Job, key: &Path, cx: &Cx) -> Result<(), String> { let mount = |sub: &str| format!("{}:/{sub}:Z", dir.join(sub).display()); cx.send(Event::Line(job, "creating Windows VM".into())); check( - Command::new("podman") + podman() .args(["run", "-d", "--name", VM]) .args([ "-e", @@ -479,7 +479,7 @@ fn start_windows(job: Job, source: &Path, key: &Path, cx: &Cx) -> Result<(), Str if !podman_ok(&["container", "exists", VM]) { create_windows(job, key, cx)?; } else if !container_running(VM) { - check(Command::new("podman").args(["start", VM]))?; + check(podman().args(["start", VM]))?; } wait_ssh(job, key, cx)?; while !ssh_ok_with( @@ -611,8 +611,19 @@ fn ssh_ok_with(key: &Path, command: &str) -> bool { .is_ok_and(|s| s.success()) } +fn podman() -> Command { + let mut cmd = Command::new("podman"); + if let Some(runtime) = std::env::var_os("XDG_RUNTIME_DIR") { + let mut bus = std::ffi::OsString::from("unix:path="); + bus.push(runtime); + bus.push("/bus"); + cmd.env("DBUS_SESSION_BUS_ADDRESS", bus); + } + cmd +} + fn podman_ok(args: &[&str]) -> bool { - Command::new("podman") + podman() .args(args) .stdout(Stdio::null()) .stderr(Stdio::null()) @@ -625,7 +636,14 @@ fn check(cmd: &mut Command) -> Result<(), String> { if out.status.success() { Ok(()) } else { - Err(String::from_utf8_lossy(&out.stderr).trim().to_string()) + let stderr = String::from_utf8_lossy(&out.stderr); + Err(stderr + .lines() + .rev() + .find(|line| !line.trim().is_empty()) + .unwrap_or_default() + .trim() + .to_string()) } }