Skip to content
Merged
68 changes: 68 additions & 0 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1673,6 +1673,72 @@ run_onboard() {
fi
}

# Make sure Docker is installed and the current user can run it without
# sudo. If we install Docker or add the user to the docker group, exit with
# instructions to relogin/newgrp — Linux only loads group membership at
# login, so the rest of this script (onboard, etc.) would fail otherwise.
# Skipped on macOS (Docker Desktop) and inside WSL (host-managed Docker).
ensure_docker() {
case "$(uname -s)" in
Darwin | MINGW* | MSYS*) return 0 ;;
esac
if [ -n "${WSL_DISTRO_NAME:-}" ] || [ -n "${WSL_INTEROP:-}" ]; then
return 0
fi
# Fast path: docker info works → already set up (root, or already-active group).
if docker info >/dev/null 2>&1; then
return 0
Comment on lines +1689 to +1691

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

Does docker infouse the current Docker context and theDOCKER_HOST/DOCKER_CONTEXT environment variables, and what is the recommended way for a Linux shell script to force a check against the local Docker daemon/socket?

💡 Result:

Yes. docker info (alias of docker system info) connects to whatever daemon endpoint the Docker CLI is configured to use, which is determined by the active Docker context unless overridden by higher-priority connection settings like DOCKER_HOST/--host/-H. The Docker docs state that commands run against the current context “unless overridden with environment variables such as DOCKER_HOST and DOCKER_CONTEXT,” or with --context/--host flags [1]. Also, DOCKER_CONTEXT overrides the context selected via docker context use when the environment variable is set [1][2]. Separately, the CLI reference describes DOCKER_HOST as the “Daemon socket to connect to” and that -c/--context overrides DOCKER_HOST only relative to default context selection; and the context commands explain DOCKER_HOST/DOCKER_CONTEXT and flags affect what daemon is used [3]. The docker info page shows “Client/Context: …” in its output, confirming it reports the client-side context it’s using [4]. Recommended way (Linux shell script) to force a check against the local Docker daemon/socket: run docker info with an explicit host override to the local Unix socket and clear any env overrides that could redirect the CLI. Docker provides troubleshooting guidance that if DOCKER_HOST is set then the Docker client is connecting to a daemon on that host, and recommends unsetting it when you want local behavior [5]. So in a script, do something like: unset DOCKER_HOST DOCKER_CONTEXT export DOCKER_CONTEXT=default # optional; ensures you’re not using a non-local named context # Force local daemon via unix socket (typical rootful Docker): docker --host unix:///var/run/docker.sock info >/dev/null If you’re using rootless Docker, the socket is typically under $XDG_RUNTIME_DIR/docker.sock as documented; you’d use that path instead of /var/run/docker.sock [6]. This approach forces the check against the intended local socket regardless of whatever current context the user/session has selected via docker context use or environment variables such as DOCKER_CONTEXT, because DOCKER_HOST is either unset or the connection is overridden explicitly via --host/socket URI [1][5].

Citations:


🏁 Script executed:

# First, check if the file exists and its size
wc -l scripts/install.sh

# Then read the specific sections mentioned in the review
echo "=== Lines 1680-1695 (around 1689-1691) ==="
sed -n '1680,1695p' scripts/install.sh

echo -e "\n=== Lines 1718-1735 (around 1725-1728) ==="
sed -n '1718,1735p' scripts/install.sh

echo -e "\n=== Lines 1754-1770 (around 1761-1762) ==="
sed -n '1754,1770p' scripts/install.sh

# Check for SPDX header
echo -e "\n=== First 5 lines of file (SPDX header check) ==="
head -5 scripts/install.sh

# Check for shebang
echo -e "\n=== Shebang check ==="
head -1 scripts/install.sh

Repository: NVIDIA/NemoClaw

Length of output: 2330


Force Docker reachability checks against the local daemon socket, not the active Docker context.

The bare docker info checks on lines 1689-1691, 1725-1728, and 1761-1762 honor the user's current Docker context and DOCKER_HOST environment variables. If the user has Docker pointed at a remote or stale endpoint, the preflight will falsely fail or take the wrong remediation path even though the local daemon is accessible. Explicitly target the local Unix socket using docker --host unix:///var/run/docker.sock info (or the rootless equivalent under $XDG_RUNTIME_DIR/docker.sock).

🤖 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/install.sh` around lines 1689 - 1691, The script's fast-path and
preflight checks use plain `docker info`, which respects DOCKER_HOST/contexts;
update each occurrence of `docker info` (the checks in the install.sh
preflight/fast-path logic) to explicitly target the local daemon socket by
invoking `docker --host unix:///var/run/docker.sock info` and, when
`$XDG_RUNTIME_DIR` is set (rootless), try `docker --host
unix://$XDG_RUNTIME_DIR/docker.sock info` as a fallback; ensure the check treats
success the same way as before and try the rootful socket first, then the
rootless socket, falling back to the original `docker info` only if both socket
checks fail.

fi

local group_added=0

if ! command -v docker >/dev/null 2>&1; then
info "Docker is not installed."
info "The next step uses sudo to install Docker system-wide via the official convenience script. You may be prompted for your password."
local docker_tmp
docker_tmp="$(mktemp)"
if ! curl -fsSL https://get.docker.com -o "$docker_tmp"; then
rm -f "$docker_tmp"
error "Failed to download the Docker convenience script from https://get.docker.com"
fi
verify_downloaded_script "$docker_tmp" "Docker installer"
if ! sudo sh "$docker_tmp"; then
rm -f "$docker_tmp"
error "Docker install failed. Install Docker manually and re-run."
fi
rm -f "$docker_tmp"
fi
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

if command -v systemctl >/dev/null 2>&1 \
&& ! sudo -n systemctl is-active --quiet docker 2>/dev/null \
&& ! systemctl is-active --quiet docker 2>/dev/null; then
info "The Docker daemon is not running."
info "The next step uses sudo to enable and start the docker.service unit. You may be prompted for your password."
if ! sudo systemctl enable --now docker 2>/dev/null; then
warn "Could not enable docker.service — will verify daemon accessibility below."
fi
fi
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

if ! id -nG "$USER" 2>/dev/null | tr ' ' '\n' | grep -qx docker; then
info "Your user '$USER' is not in the docker group."
info "The next step uses sudo to add you to the group so docker works without sudo. You may be prompted for your password."
sudo usermod -aG docker "$USER"
group_added=1
fi

if [ "$group_added" = "1" ]; then
printf "\n"
info "Docker setup complete. To finish:"
info " 1) Run: newgrp docker (or log out and log back in)"
info " 2) Re-run: curl -fsSL https://www.nvidia.com/nemoclaw.sh | bash"
exit 0
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
Comment on lines +1753 to +1758

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Don’t tell users to rerun a different installer invocation.

This exit path runs after args/env have already been parsed, so the hardcoded one-liner drops flags like --non-interactive, --fresh, NEMOCLAW_AGENT, or explicit acceptance. In headless or customized installs, following this message can change behavior or fail on the next run. Tell the user to rerun the same command they used originally, or reconstruct it from the current args/env.

Suggested tweak
-    info "  2) Re-run: curl -fsSL https://www.nvidia.com/nemoclaw.sh | bash"
+    info "  2) Re-run the same installer command you used originally, with the same flags/env."
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [ "$needs_group_refresh" = "1" ]; then
printf "\n"
info "Docker group membership is not active in this shell yet. To finish:"
info " 1) Run: newgrp docker (or log out and log back in)"
info " 2) Re-run: curl -fsSL https://www.nvidia.com/nemoclaw.sh | bash"
exit 0
if [ "$needs_group_refresh" = "1" ]; then
printf "\n"
info "Docker group membership is not active in this shell yet. To finish:"
info " 1) Run: newgrp docker (or log out and log back in)"
info " 2) Re-run the same installer command you used originally, with the same flags/env."
exit 0
🤖 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/install.sh` around lines 1753 - 1758, The exit message when
needs_group_refresh=1 currently tells users to rerun a hardcoded installer
one-liner; update the messaging and/or implementation to instruct the user to
re-run the exact command they originally invoked (preserving flags and
environment) instead of the fixed curl line. Replace the hardcoded "curl -fsSL
https://www.nvidia.com/nemoclaw.sh | bash" suggestion with a reconstructed
invocation using the script name and original arguments (e.g., "$0 $@" or
equivalent) and include a note to preserve any important env vars
(NEMOCLAW_AGENT, --non-interactive, --fresh, etc.) so the re-run uses the same
options; keep the same needs_group_refresh exit path and exit status.

fi

if ! docker info >/dev/null 2>&1; then
error "Docker is installed but not reachable. Try: sudo systemctl start docker"
fi
}

# Main
# ---------------------------------------------------------------------------
main() {
Expand Down Expand Up @@ -1725,6 +1791,8 @@ main() {
# still collect acceptance before Node.js or the CLI are installed.
preflight_usage_notice_prompt

ensure_docker

_INSTALL_START=$SECONDS
print_banner
bash "${SCRIPT_DIR}/setup-jetson.sh"
Expand Down
Loading