Repository navigation
fix(cli): run global updates from the home directory - #8131
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
Edit accuracy: accurate 271 (base branch 271), smooth 61 of thoseThe gate passes. Quarantined, measured but not gated (0) |
jrusso1020
left a comment
There was a problem hiding this comment.
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
cwdfromglobalInstallCwd():upgradeRunningCli(hyperframes update) andrunDetectedInstall(upgrade --yes);- both
brewInstalledVersioncalls; - the detached
node -einstaller; - the
execFileinside the installer script.
- Nothing else in the update path runs in the project folder. The
npx skillscalls incommands/skills.tsalready usednpxCwd(), and installer detection spawns nothing. - Windows:
process.geteuidis undefined there, so only the absolute, directory andX_OKchecks apply.homedir()resolves toUSERPROFILE, which passes them. - The detached installer resolves
configFileandrunningDirbefore it changes directory. The new fixture test proves the manager runs in the chosen home with no projectbunfig.tomlin 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
- 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 exampleregistry). The installers inheritprocess.env, so the cwd change does not cover that path. Clearingnpm_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. sudoupgrades now fail with a misleading message. WheresudokeepsHOME(macOS's default sudoers, for example), euid is 0 but the home folder belongs to the user. The ownership check then returns null, andsudo hyperframes upgrade --yesreports "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.- 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
left a comment
There was a problem hiding this comment.
Approving at 79824d0. All three earlier findings are addressed.
- Package-script environment.
globalInstallLocation()now refuses whenevernpm_lifecycle_eventis 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. sudowith another user's home. The message now names the ownership mismatch and how to fix it.- 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
--jsonstdout 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.
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
bunfig.toml.