From 5656d430ff03b00683bd8fdc0786a8762b4f8924 Mon Sep 17 00:00:00 2001 From: Mitchell R Date: Wed, 13 May 2026 03:13:39 +0200 Subject: [PATCH] fix(deploy): run cargo build under a login shell sudo -u cargo fails when cargo lives in ~/.cargo/bin and root's PATH doesn't carry it. Switch to sudo -u -i sh -c so the user's .profile / cargo env is sourced. --- deploy/scripts/setup-pi-kiosk.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/deploy/scripts/setup-pi-kiosk.sh b/deploy/scripts/setup-pi-kiosk.sh index 609e1d3..38ffcb0 100644 --- a/deploy/scripts/setup-pi-kiosk.sh +++ b/deploy/scripts/setup-pi-kiosk.sh @@ -62,10 +62,6 @@ BIN_DST_DIR="/opt/betterframe/kiosk" BIN_DST="${BIN_DST_DIR}/betterframe-kiosk" if [ "${SKIP_BUILD:-0}" != "1" ]; then - if ! command -v cargo >/dev/null 2>&1; then - echo "error: cargo not found. Install rustup or set SKIP_BUILD=1." >&2 - exit 1 - fi apt-get install -y --no-install-recommends \ libgtk-4-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \ libwebkitgtk-6.0-dev pkg-config build-essential \ @@ -73,10 +69,11 @@ if [ "${SKIP_BUILD:-0}" != "1" ]; then gstreamer1.0-plugins-bad gstreamer1.0-libav # Build as the invoking user (typically the dev/admin user), not root, - # so cargo registry caches stay in their home. + # so cargo registry caches stay in their home and rustup PATH applies. + # -i runs a login shell so ~/.cargo/env gets sourced from .profile/.bashrc. BUILD_USER="${SUDO_USER:-root}" echo " building as ${BUILD_USER}" - sudo -u "${BUILD_USER}" cargo build --release --manifest-path "${REPO_ROOT}/kiosk/Cargo.toml" + sudo -u "${BUILD_USER}" -i sh -c "cd '${REPO_ROOT}' && cargo build --release --manifest-path kiosk/Cargo.toml" fi if [ ! -f "${BIN_SRC}" ]; then