Skip to content

fix(cli): run global updates from the home directory - #8131

Merged
terencecho merged 2 commits into
mainfrom
fix/cli-update-working-directory
Nov 18, 2026
Merged

terencecho merged 2 commits into
mainfrom
fix/cli-update-working-directory

Conversation

@terencecho

@terencecho terencecho commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What changed

Global CLI updates now start the package manager in the user's home directory. This applies to hyperframes update, hyperframes upgrade --yes, and both processes used for background installation. Project-local package-manager settings should apply only to project operations.

When a package script invokes the CLI, self-installation is skipped so the manager cannot inherit project settings or the script’s executable search path. When the home directory is unsuitable, the CLI explains the ownership, permissions, or accessibility problem. Background diagnostics go to stderr so they can be seen without opening a log in the rejected home. The detached installer resolves its settings and running-process paths before changing directories so relative configuration paths still work.

Verification

  • 198 tests passed across the CLI update, upgrade, installer detection, and update-check suites.
  • The command tests check the working directory for npm, pnpm, Bun, and Homebrew. A subprocess test starts the detached installer in a fixture project and verifies that its manager sees the selected home and no project-local bunfig.toml.
  • The CLI build, typecheck, formatting, and lint passed.

@mintlify

mintlify Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
hyperframes 🟢 Ready View Preview Nov 18, 2026, 3:08 AM

💡 Tip: Enable Automations to automatically generate PRs for you.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 271 (base branch 271), smooth 61 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (0)

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approving at 8af50c1. Every global-install spawn now starts in the home directory, and the failure paths stop before a package manager runs.

Checked

  • All four spawns get cwd from globalInstallCwd():
    • upgradeRunningCli (hyperframes update) and runDetectedInstall (upgrade --yes);
    • both brewInstalledVersion calls;
    • the detached node -e installer;
    • the execFile inside the installer script.
  • Nothing else in the update path runs in the project folder. The npx skills calls in commands/skills.ts already used npxCwd(), and installer detection spawns nothing.
  • Windows: process.geteuid is undefined there, so only the absolute, directory and X_OK checks apply. homedir() resolves to USERPROFILE, which passes them.
  • The detached installer resolves configFile and runningDir before it changes directory. The new fixture test proves the manager runs in the chosen home with no project bunfig.toml in sight.
  • If spawn returns with no pid (the cwd vanished), the code now throws into the existing catch. The new test confirms that path clears pendingUpdate.

Non-blocking

  1. Project npm config can still arrive through the environment. When the global CLI runs from an npm/pnpm package script, the parent package manager exports its resolved config as npm_config_*, including values from the project's .npmrc (for example registry). The installers inherit process.env, so the cwd change does not cover that path. Clearing npm_config_* (and pnpm's and Bun's equivalents) from the child env would close it. I traced this from the code and did not run it.
  2. sudo upgrades now fail with a misleading message. Where sudo keeps HOME (macOS's default sudoers, for example), euid is 0 but the home folder belongs to the user. The ownership check then returns null, and sudo hyperframes upgrade --yes reports "Cannot upgrade the CLI without a usable home directory." Linux global npm prefixes often need sudo, so either accept a root-owned or euid-0 run, or name the actual reason in the message.
  3. Group-writable homes skip updates silently. A home with mode 0775 (some shared or managed setups) turns off background updates with nothing logged. A log() line when the home is rejected would make that visible in the update log.

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approving at 79824d0. All three earlier findings are addressed.

  1. Package-script environment. globalInstallLocation() now refuses whenever npm_lifecycle_event is set. npm, pnpm and Bun all set it for package scripts, so neither the project's exported config nor its PATH reaches a global installer. That covers both foreground paths and the background one. The background check now runs before the CLI registers its running record.
  2. sudo with another user's home. The message now names the ownership mismatch and how to fix it.
  3. Group-writable home. The rejection is now specific. A background skip reports its reason on stderr and does not write a log into the rejected home. That keeps --json stdout clean.

The order change in scheduleBackgroundInstall is fine. The installer and home checks now run before registeredAsRunning, so a CLI with no installer (a project-local or npx run) never sees the stderr line.

CI: the only red is Studio: edit accuracy gate. Two Studio undo/nudge cases regressed (seqresizeundo-none-pct-r0-nested-z100, seqnudge-none-center-r0-root-z100) and both are on the gate's own unstable list. A re-run failed the same way. This PR touches only packages/cli and the CLI docs, so it cannot move Studio edit accuracy; that gate needs a re-run or a baseline fix, not a change here. The cancelled CI run 44228311263 is the duplicate of run 44228280967.

@terencecho
terencecho added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit e99cd75 Nov 18, 2026
331 of 357 checks passed
@terencecho
terencecho deleted the fix/cli-update-working-directory branch November 18, 2026 05:00

This branch was successfully deployed

1 active deployment
staging - docs — 79824d02 Deployed Nov 18, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants