Repository navigation
fix(autoinstall): detect root + cover libc++ runtime in compiler-unix.sh - #1008
Conversation
Two genuine bugs in the Linux auto-install path that have been forcing
Dockerfile.alb (and prospective Dockerfile.model-server) to duplicate
the dependency list manually instead of relying on `--autoinstall`:
1. `sudo` was used unconditionally. In a Docker container running as
root (no sudo on PATH), the script crashed before installing any
package — even the "install sudo" command was prefixed with sudo.
Fix: detect `[ "$EUID" -eq 0 ]` at script start, derive `$SUDO`
accordingly, and substitute throughout. The check_linux_sudo step
early-returns when running as root (no point installing sudo).
2. libc++ runtime packages were missing from REQUIRES. The build
variants (`libc++-${CLANG_VERSION}-dev`) were covered for compile,
but the prebuilt engine downloaded during `--autoinstall`'s pip
bootstrap is linked against clang's libc++/libc++abi and needs the
*runtime* libs (libc++1, libc++abi1) to execute. Plus libgomp1 for
a few OMP-using transitive deps.
Both findings come from rocketride-ai/rocketride-saas PR #145's own
patch comments — that PR worked around the bugs in the Dockerfile
instead of fixing them at the source. With this change, Dockerfiles
that ship Node 20 + pnpm + the saas source tree can run
`./builder saas:build --autoinstall` and have the C++ toolchain
self-install correctly on a clean Ubuntu base, with no manual apt
duplication.
|
No description provided. |
📝 WalkthroughWalkthroughThis PR centralizes sudo handling in ChangesLinux build script root-aware sudo handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
scripts/compiler-unix.sh (1)
293-351:⚠️ Potential issue | 🟠 Major | ⚡ Quick winRoot mode still incorrectly treats
sudoas a required dependency.Line 294 unconditionally adds
sudotoREQUIRES, and Lines 343-348 can enqueueapt install -y sudoeven when Line 231 detected root (SUDO=""). This undermines the root/no-sudo fix and can fail in minimal images wheresudois intentionally absent.Suggested fix
check_linux_dependencies() { check_linux_sudo check_linux_cmake check_linux_python REQUIRES+=( - "sudo" "curl" "wget" "dos2unix" @@ "libc++abi1" "libgomp1" ) + + # sudo is only required when we are not already root + if [ -n "$SUDO" ]; then + REQUIRES+=("sudo") + fi🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@scripts/compiler-unix.sh` around lines 293 - 351, The script currently unconditionally adds "sudo" to the REQUIRES array and later enqueues apt install for it even when running as root; change the REQUIRES population to only append "sudo" when the SUDO detection indicates non-root (i.e., SUDO is non-empty) or, alternatively, in the package-check loop (the for package in "${REQUIRES[@]}" ... case "sudo") skip enqueueing/install when SUDO is empty; update the REQUIRES assignment or the case "sudo" branch so that command_exists checks and COMMANDS+=("apt install -y sudo") only run when SUDO is set, referencing the REQUIRES array, the for ... case loop, and the SUDO variable/command_exists check.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/compiler-unix.sh`:
- Line 356: The apt install entry added to the COMMANDS array is interactive;
update the COMMANDS+=(" $SUDO apt install gnupg") entry to run
non-interactively by setting DEBIAN_FRONTEND=noninteractive and using the
noninteractive flags (e.g., apt-get -y install) so unattended --autoinstall runs
won't prompt; modify the COMMANDS array item that contains "$SUDO apt install
gnupg" accordingly.
---
Outside diff comments:
In `@scripts/compiler-unix.sh`:
- Around line 293-351: The script currently unconditionally adds "sudo" to the
REQUIRES array and later enqueues apt install for it even when running as root;
change the REQUIRES population to only append "sudo" when the SUDO detection
indicates non-root (i.e., SUDO is non-empty) or, alternatively, in the
package-check loop (the for package in "${REQUIRES[@]}" ... case "sudo") skip
enqueueing/install when SUDO is empty; update the REQUIRES assignment or the
case "sudo" branch so that command_exists checks and COMMANDS+=("apt install -y
sudo") only run when SUDO is set, referencing the REQUIRES array, the for ...
case loop, and the SUDO variable/command_exists check.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: b810ae07-6556-4712-9513-80db1ef010a9
📒 Files selected for processing (1)
scripts/compiler-unix.sh
anandray
left a comment
There was a problem hiding this comment.
LGTM. sudo → $SUDO switch is consistent across all 11 callsites ($EUID works with the bash shebang), and the libc++ runtime add with the explicit dpkg -l case keeps reruns idempotent. CR's gnupg finding (line 356 lacks -y) is a real bug worth fixing in a follow-up — it's the only apt install in the file without -y and will block under --autoinstall in a Docker build.
The gnupg install command in check_linux_dependencies() was missing the `-y` flag — the only `apt install` line in the file without it. Under `--autoinstall` in a non-interactive context (Docker build, CI runner), apt prompts for confirmation and blocks waiting on stdin that will never come, hanging the build until timeout. Follow-up to #1008 — flagged by CodeRabbit and Anand as worth splitting out. One-character fix. Co-authored-by: Dmitrii Kataraev <dmitrii.kataraev@rocketride.ai>
….sh (rocketride-org#1008) Two genuine bugs in the Linux auto-install path that have been forcing Dockerfile.alb (and prospective Dockerfile.model-server) to duplicate the dependency list manually instead of relying on `--autoinstall`: 1. `sudo` was used unconditionally. In a Docker container running as root (no sudo on PATH), the script crashed before installing any package — even the "install sudo" command was prefixed with sudo. Fix: detect `[ "$EUID" -eq 0 ]` at script start, derive `$SUDO` accordingly, and substitute throughout. The check_linux_sudo step early-returns when running as root (no point installing sudo). 2. libc++ runtime packages were missing from REQUIRES. The build variants (`libc++-${CLANG_VERSION}-dev`) were covered for compile, but the prebuilt engine downloaded during `--autoinstall`'s pip bootstrap is linked against clang's libc++/libc++abi and needs the *runtime* libs (libc++1, libc++abi1) to execute. Plus libgomp1 for a few OMP-using transitive deps. Both findings come from rocketride-ai/rocketride-saas PR rocketride-org#145's own patch comments — that PR worked around the bugs in the Dockerfile instead of fixing them at the source. With this change, Dockerfiles that ship Node 20 + pnpm + the saas source tree can run `./builder saas:build --autoinstall` and have the C++ toolchain self-install correctly on a clean Ubuntu base, with no manual apt duplication. Co-authored-by: Dmitrii Kataraev <dmitrii.kataraev@rocketride.ai>
…org#1009) The gnupg install command in check_linux_dependencies() was missing the `-y` flag — the only `apt install` line in the file without it. Under `--autoinstall` in a non-interactive context (Docker build, CI runner), apt prompts for confirmation and blocks waiting on stdin that will never come, hanging the build until timeout. Follow-up to rocketride-org#1008 — flagged by CodeRabbit and Anand as worth splitting out. One-character fix. Co-authored-by: Dmitrii Kataraev <dmitrii.kataraev@rocketride.ai>
Summary
Two genuine bugs in
scripts/compiler-unix.sh's auto-install path that have been forcing downstream Dockerfiles (notablyrocketride-ai/rocketride-saas/docker/Dockerfile.albper the closed PR #145) to duplicate the apt dependency list by hand instead of relying on--autoinstall:1.
sudoused unconditionallyIn a Docker container running as root (no
sudoon PATH), the script crashed before installing any package — even the "install sudo" recovery command was prefixed withsudo. Fixed by detecting[ "$EUID" -eq 0 ]at script start, deriving$SUDOaccordingly, and substituting throughout the COMMANDS array and direct apt invocations.check_linux_sudoearly-returns when running as root.2. libc++ runtime packages missing from REQUIRES
Build variants (
libc++-${CLANG_VERSION}-dev) were already conditionally added — sufficient for compile. But the prebuilt engine binary downloaded during--autoinstall's pip bootstrap is linked against clang'slibc++/libc++abi(not GNUlibstdc++), so executing it fails with:Added
libc++1,libc++abi1,libgomp1to REQUIRES with an explicit case in the dependency check switch (these are libraries with no CLI command, so the existingcommand_existsdefault would have created install commands unconditionally on every rerun — explicitdpkg -lcheck is idempotent).Source
Both findings come from PR #145's own patch comments — that PR worked around the bugs in the Dockerfile instead of fixing them at the source. Per Rod's directive to root-cause-fix rather than paper-over, this PR puts the fixes in the autoinstall script itself.
Test plan
bash -n scripts/compiler-unix.shpasses (syntax)ubuntu:22.04Docker stage and prove the path works without manual apt duplicationBackwards compat
$SUDOresolves to"sudo").libc++1etc. are no-ops via thedpkg -l ... grep -q "^ii"check.--autoinstallflag semantics.Summary by CodeRabbit
Release Notes
Bug Fixes
Chores