fix(install): pin OpenShell to 0.0.22, upgrade on mismatch#1459
fix(install): pin OpenShell to 0.0.22, upgrade on mismatch#1459
Conversation
Upgrading NemoClaw did not upgrade OpenShell because (1) onboard.js only checked binary presence, not version, and (2) install-openshell.sh had a hardcoded MIN_VERSION floor of 0.0.7 and always downloaded the latest release. Add openshellVersion pin to package.json as single source of truth. The install script now reads OPENSHELL_PIN_VERSION env var to download that exact tagged release and treat it as the minimum required version. Onboard compares the installed version against the pin and triggers an upgrade when the installed version is too old. Fixes: NVBug 6044568 Signed-off-by: Aaron Erickson <aerickson@nvidia.com>
📝 WalkthroughWalkthroughAdded a semver comparison helper Changes
Sequence DiagramsequenceDiagram
participant PkgJson as package.json
participant Onboard as bin/lib/onboard.js
participant InstallScript as scripts/install-openshell.sh
participant GitHub as GitHub Releases
Onboard->>PkgJson: Read openshellVersion
PkgJson-->>Onboard: "0.0.22"
Onboard->>Onboard: getInstalledOpenshellVersion()
Onboard->>Onboard: versionGte(installed, pinned)?
alt missing or version < pinned
Onboard->>InstallScript: spawnSync with env (OPENSHELL_PIN_VERSION=0.0.22)
InstallScript->>GitHub: gh release download --tag v0.0.22 / curl .../releases/download/v0.0.22/...
GitHub-->>InstallScript: Release artifact
InstallScript-->>Onboard: Installation complete
else version sufficient
Onboard-->>Onboard: Skip installation
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
No longer relev |
…sion Signed-off-by: Aaron Erickson <aerickson@nvidia.com> # Conflicts: # scripts/install-openshell.sh
…fix/pin-openshell-version
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
bin/lib/onboard.js (1)
2070-2084: Extract the OpenShell gate into a helper to keeppreflight()complexity under control.This block is functionally good, but it adds more branching inside an already complex function. Consider moving this logic to a dedicated helper and reusing a single cached
openshellVersionconstant.♻️ Suggested refactor
+const { openshellVersion: OPEN_SHELL_PIN_VERSION } = require("../../package.json"); + +function getOpenshellInstallDecision(installedVersion, pinnedVersion = OPEN_SHELL_PIN_VERSION) { + const needsInstall = + !installedVersion || (pinnedVersion && !versionGte(installedVersion, pinnedVersion)); + return { needsInstall, pinnedVersion }; +} + function installOpenshell() { - const pinnedVersion = require("../../package.json").openshellVersion; + const pinnedVersion = OPEN_SHELL_PIN_VERSION; const installEnv = { ...process.env }; if (pinnedVersion) { installEnv.OPENSHELL_PIN_VERSION = pinnedVersion; } ... } // inside preflight() - const pinnedOpenshellVersion = require("../../package.json").openshellVersion; let openshellInstall = { localBin: null, futureShellPathHint: null }; const installedOpenshellVersion = isOpenshellInstalled() ? getInstalledOpenshellVersion() : null; - const needsInstall = - !installedOpenshellVersion || - (pinnedOpenshellVersion && !versionGte(installedOpenshellVersion, pinnedOpenshellVersion)); + const { needsInstall, pinnedVersion: pinnedOpenshellVersion } = + getOpenshellInstallDecision(installedOpenshellVersion);As per coding guidelines, "Enforce cyclomatic complexity limit of 20 (ratcheting down to 15) via ESLint".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@bin/lib/onboard.js` around lines 2070 - 2084, Extract the OpenShell install/upgrade gate out of preflight() into a new helper e.g. ensureOpenshellPresent(), moving the logic that reads pinnedOpenshellVersion, checks isOpenshellInstalled(), calls getInstalledOpenshellVersion(), computes needsInstall with versionGte(), and returns the openshellInstall object (localBin/futureShellPathHint) and installed/pinned versions; replace the inlined block in preflight() with a single call to ensureOpenshellPresent() and use a single cached constant for pinnedOpenshellVersion (read once) to avoid repeated file reads and reduce cyclomatic complexity.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@scripts/install-openshell.sh`:
- Around line 88-95: Add a validation step for OPENSHELL_PIN_VERSION before
using it: check OPENSHELL_PIN_VERSION against a strict semver regex (e.g.,
major.minor.patch with optional pre-release/build) and if it fails print a clear
error via info or echo and exit non‑zero; only then set GH_TAG_FLAG and
CURL_TAG_PATH and log "Pinned to OpenShell v${OPENSHELL_PIN_VERSION}". Update
the branch that assigns GH_TAG_FLAG, CURL_TAG_PATH and the info message
(references: GH_TAG_FLAG, CURL_TAG_PATH, OPENSHELL_PIN_VERSION) to perform this
guard so malformed values won't reach the download/checksum stages.
---
Nitpick comments:
In `@bin/lib/onboard.js`:
- Around line 2070-2084: Extract the OpenShell install/upgrade gate out of
preflight() into a new helper e.g. ensureOpenshellPresent(), moving the logic
that reads pinnedOpenshellVersion, checks isOpenshellInstalled(), calls
getInstalledOpenshellVersion(), computes needsInstall with versionGte(), and
returns the openshellInstall object (localBin/futureShellPathHint) and
installed/pinned versions; replace the inlined block in preflight() with a
single call to ensureOpenshellPresent() and use a single cached constant for
pinnedOpenshellVersion (read once) to avoid repeated file reads and reduce
cyclomatic complexity.
🪄 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: CHILL
Plan: Pro
Run ID: f2bd867e-2044-498a-bbd2-84eed0544134
📒 Files selected for processing (4)
bin/lib/onboard.jspackage.jsonscripts/install-openshell.shtest/onboard.test.js
✅ Files skipped from review due to trivial changes (2)
- package.json
- test/onboard.test.js
| # When a pin is set, download that exact tag; otherwise download latest. | ||
| GH_TAG_FLAG=() | ||
| CURL_TAG_PATH="latest/download" | ||
| if [[ -n "${OPENSHELL_PIN_VERSION:-}" ]]; then | ||
| GH_TAG_FLAG=(--tag "v${OPENSHELL_PIN_VERSION}") | ||
| CURL_TAG_PATH="download/v${OPENSHELL_PIN_VERSION}" | ||
| info "Pinned to OpenShell v${OPENSHELL_PIN_VERSION}" | ||
| fi |
There was a problem hiding this comment.
Validate OPENSHELL_PIN_VERSION format before using it.
If the env var is malformed, the script fails later during download/checksum with less actionable errors. Add an early semver-format guard for better reliability.
🛡️ Suggested hardening
if [[ -n "${OPENSHELL_PIN_VERSION:-}" ]]; then
+ if [[ ! "${OPENSHELL_PIN_VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
+ fail "Invalid OPENSHELL_PIN_VERSION '${OPENSHELL_PIN_VERSION}' (expected X.Y.Z)"
+ fi
GH_TAG_FLAG=(--tag "v${OPENSHELL_PIN_VERSION}")
CURL_TAG_PATH="download/v${OPENSHELL_PIN_VERSION}"
info "Pinned to OpenShell v${OPENSHELL_PIN_VERSION}"
fi📝 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.
| # When a pin is set, download that exact tag; otherwise download latest. | |
| GH_TAG_FLAG=() | |
| CURL_TAG_PATH="latest/download" | |
| if [[ -n "${OPENSHELL_PIN_VERSION:-}" ]]; then | |
| GH_TAG_FLAG=(--tag "v${OPENSHELL_PIN_VERSION}") | |
| CURL_TAG_PATH="download/v${OPENSHELL_PIN_VERSION}" | |
| info "Pinned to OpenShell v${OPENSHELL_PIN_VERSION}" | |
| fi | |
| # When a pin is set, download that exact tag; otherwise download latest. | |
| GH_TAG_FLAG=() | |
| CURL_TAG_PATH="latest/download" | |
| if [[ -n "${OPENSHELL_PIN_VERSION:-}" ]]; then | |
| if [[ ! "${OPENSHELL_PIN_VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| fail "Invalid OPENSHELL_PIN_VERSION '${OPENSHELL_PIN_VERSION}' (expected X.Y.Z)" | |
| fi | |
| GH_TAG_FLAG=(--tag "v${OPENSHELL_PIN_VERSION}") | |
| CURL_TAG_PATH="download/v${OPENSHELL_PIN_VERSION}" | |
| info "Pinned to OpenShell v${OPENSHELL_PIN_VERSION}" | |
| fi |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@scripts/install-openshell.sh` around lines 88 - 95, Add a validation step for
OPENSHELL_PIN_VERSION before using it: check OPENSHELL_PIN_VERSION against a
strict semver regex (e.g., major.minor.patch with optional pre-release/build)
and if it fails print a clear error via info or echo and exit non‑zero; only
then set GH_TAG_FLAG and CURL_TAG_PATH and log "Pinned to OpenShell
v${OPENSHELL_PIN_VERSION}". Update the branch that assigns GH_TAG_FLAG,
CURL_TAG_PATH and the info message (references: GH_TAG_FLAG, CURL_TAG_PATH,
OPENSHELL_PIN_VERSION) to perform this guard so malformed values won't reach the
download/checksum stages.
Summary
openshellVersion: "0.0.22"topackage.jsonas single source of truth for the required OpenShell CLI versioninstall-openshell.shnow readsOPENSHELL_PIN_VERSIONenv var to download that exact tagged release (not latest) and treats it as the minimum required versiononboard.jscompares the installed OpenShell version against the pin and triggers an upgrade when below — previously it only checked binary presenceTest plan
npm testpasses (new tests forversionGteand install script pin awareness)install-openshell.sh(no env var) still downloads latest and uses 0.0.22 floorFixes NVBug 6044568
Summary by CodeRabbit
New Features
Tests