Skip to content

fix(autoinstall): detect root + cover libc++ runtime in compiler-unix.sh - #1008

Merged
kwit75 merged 1 commit into
developfrom
dmitrii/compiler-unix-root-detection-libcxx-runtime
May 27, 2026
Merged

kwit75 merged 1 commit into
developfrom
dmitrii/compiler-unix-root-detection-libcxx-runtime

Conversation

@kwit75

@kwit75 kwit75 commented May 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Two genuine bugs in scripts/compiler-unix.sh's auto-install path that have been forcing downstream Dockerfiles (notably rocketride-ai/rocketride-saas/docker/Dockerfile.alb per the closed PR #145) to duplicate the apt dependency list by hand instead of relying on --autoinstall:

1. sudo used unconditionally

In a Docker container running as root (no sudo on PATH), the script crashed before installing any package — even the "install sudo" recovery command was prefixed with sudo. Fixed by detecting [ "$EUID" -eq 0 ] at script start, deriving $SUDO accordingly, and substituting throughout the COMMANDS array and direct apt invocations. check_linux_sudo early-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's libc++/libc++abi (not GNU libstdc++), so executing it fails with:

error while loading shared libraries: libc++.so.1: cannot open

Added libc++1, libc++abi1, libgomp1 to REQUIRES with an explicit case in the dependency check switch (these are libraries with no CLI command, so the existing command_exists default would have created install commands unconditionally on every rerun — explicit dpkg -l check 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.sh passes (syntax)
  • CI green on this PR
  • Downstream PR in rocketride-saas (Dockerfile.model-server) will exercise the autoinstall path end-to-end in a clean ubuntu:22.04 Docker stage and prove the path works without manual apt duplication

Backwards compat

  • Non-root users see identical behavior ($SUDO resolves to "sudo").
  • Already-installed libc++1 etc. are no-ops via the dpkg -l ... grep -q "^ii" check.
  • No change to the public --autoinstall flag semantics.

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Enhanced Linux compiler setup to properly handle installations in both root and non-root environments, improving compatibility with containerized builds and automated deployment scenarios.
  • Chores

    • Updated Linux dependency installation process to include necessary runtime packages alongside development tools for more reliable builds.

Review Change Stack

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.
@kwit75
kwit75 requested a review from anandray May 27, 2026 15:23
@github-actions github-actions Bot added the builder Node builder tooling and ./builder workflows label May 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai

coderabbitai Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR centralizes sudo handling in scripts/compiler-unix.sh by introducing a SUDO variable set at startup (empty when root, otherwise sudo), then replacing all hardcoded sudo invocations with $SUDO throughout Linux compiler setup, CMake installation, and dependency auto-install logic. The Linux dependency list gains runtime packages alongside existing dev headers.

Changes

Linux build script root-aware sudo handling

Layer / File(s) Summary
SUDO variable initialization and root detection
scripts/compiler-unix.sh
EUID check at script start sets SUDO to empty when running as root or to sudo otherwise, enabling all downstream commands to conditionally invoke sudo.
Compiler setup and system tool installation with conditional sudo
scripts/compiler-unix.sh
Compiler registration via update-alternatives, the check_linux_sudo function, and CMake installation are updated to use $SUDO instead of hardcoded sudo.
Linux dependency and auto-install commands with conditional sudo
scripts/compiler-unix.sh
Linux REQUIRES list extends to include runtime packages (libc++1, libc++abi1, libgomp1), and all apt install/apt update invocations for gnupg, ca-certificates, libncurses-dev, dev headers, autoconf-archive, lsb-release, and Python build tools switch from sudo apt ... to $SUDO apt ....

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • rocketride-org/rocketride-server#807: Both PRs modify scripts/compiler-unix.sh's dependency installation logic on Linux/macOS, switching how apt/package-manager installs are scheduled for tooling like CMake.

Suggested labels

builder

Suggested reviewers

  • jmaionchi
  • Rod-Christensen

Poem

A rabbit in Docker so free,
No sudo to bother, you see—
The script checks its root,
Gives sudo the boot,
And builds without sudo decree! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the two main changes: root detection for sudo handling and addition of libc++ runtime packages in the compiler-unix.sh script.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dmitrii/compiler-unix-root-detection-libcxx-runtime

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Root mode still incorrectly treats sudo as a required dependency.

Line 294 unconditionally adds sudo to REQUIRES, and Lines 343-348 can enqueue apt install -y sudo even when Line 231 detected root (SUDO=""). This undermines the root/no-sudo fix and can fail in minimal images where sudo is 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

📥 Commits

Reviewing files that changed from the base of the PR and between a57a379 and 7bdd5c9.

📒 Files selected for processing (1)
  • scripts/compiler-unix.sh

Comment thread scripts/compiler-unix.sh Resolved

@anandray anandray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@kwit75
kwit75 merged commit dd1d86d into develop May 27, 2026
23 checks passed
@kwit75
kwit75 deleted the dmitrii/compiler-unix-root-detection-libcxx-runtime branch May 27, 2026 16:15
kwit75 added a commit that referenced this pull request May 27, 2026
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>
@coderabbitai coderabbitai Bot mentioned this pull request May 27, 2026
7 tasks
kwit75 added a commit that referenced this pull request May 29, 2026
v3.2.1 dot release. stage refreshed off develop (0 behind); compiler-unix.sh conflict resolved to #1022. Includes #1008/#1009/#1022 autoinstall, #1032 check-externals fix, #990, #993, #1010, #1013. Approved by @stepmikhaylov. CI green.
@coderabbitai coderabbitai Bot mentioned this pull request Jul 6, 2026
7 tasks
AviNormie pushed a commit to AviNormie/rocketride-server that referenced this pull request Nov 9, 2026
….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>
AviNormie pushed a commit to AviNormie/rocketride-server that referenced this pull request Nov 9, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

builder Node builder tooling and ./builder workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants