Repository navigation
Conversation
The host daemon runs provider updates with only PATH from the login shell, so NPM_CONFIG_PREFIX is lost. npm then installs into its default prefix, while bb keeps running the older CLI from the user's prefix, and the version check after the update fails. The provider maintenance kit now finds the npm prefix whose lib/node_modules/<package> holds the CLI on PATH. When that prefix is not npm's default, the install command and the npm list probe add --prefix <prefix>. Pi uses this for npm installs. Refs get-bb#4009
Contributor
|
Thanks @ryanolson for the PR. This repo approves new contributors before it reviews their PRs, so this PR now closes on its own. That is expected. Join the #contributors channel in Discord (https://discord.gg/kvBU6tJhcJ), post a link to this PR, and explain what it changes and why. A maintainer then adds you to the allow list and can reopen the PR. |
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
bb updates npm-installed providers with
npm install -g <package>@latestand no--prefix(provider-maintenance-kit.ts#L131-L137). The host daemon runs that command with its own environment plus onlyPATHfrom the login shell (command-dispatch.ts#L165-L168). SoNPM_CONFIG_PREFIXfrom the shell is lost, and npm installs into its default prefix. If the user installed the CLI into their own prefix (for exampleNPM_CONFIG_PREFIX=~/.npm-global npm install -g ...), that copy is first onPATHand stays old. The update then fails its version check with "pi update exited successfully, but the provider could not verify the installed result." Every retry does the same. Status also shows the install source asexternal, because the npm probe looks at the default prefix too.Seen with pi on macOS:
~/.npm-global/bin/pistayed at 1.1.0 while each update wrote 1.2.0 to/opt/homebrew/bin/pi. With onlyPATHset,npm prefix -gprints/opt/homebrew, and the daemon's npm logs load/opt/homebrew/etc/npmrc. On Linux the same update went to~/.pixi/envs/nodejs. #4009 reports the same thing for codex.What changed
packages/provider-bridge-protocol/src/bridge-kit/provider-maintenance-kit.ts: newnpmPrefixOwningExecutable(executablePath, npmPackage). It follows the CLI onPATHto its real path. If that path is under<prefix>/lib/node_modules/<package>(Windows: the shim folder holdsnode_modules/<package>), it returns<prefix>. It returns null when that prefix is npm's default prefix or when no npm prefix owns the CLI.npmGlobalInstallCommandandprobeNpmGlobalPackagetake an optional prefix and add--prefix <prefix>when it is set.plugins/provider-pi/src/bridge/provider-maintenance.ts: pi passes the owning prefix to the install command and to the probe. The Bun path is unchanged.packages/plugin-sdk/src/provider-bridge.ts: exportsexperimental_npmPrefixOwningExecutable. It is added to the provider maintenance toolkit entry indocs/api_to_audit.mdand to the bb-guide API index.npm install -g <package>@latest. Users whose default prefix already holds the CLI (for example Homebrew npm) see the same command as before.codex update, which does not use the kit's npm command. Claude Code also updates withclaude update. Both only get the probe default, which is unchanged.ProviderInstallationCommandwithcommand,argsanddisplayCommand; only the args differ.HOST_DAEMON_PROTOCOL_VERSIONis not changed.How you verified
plugins/provider-pi/src/bridge/provider-maintenance.npm-prefix.test.ts: builds a fake npm prefix in a temp folder (package folder withpackage.json,bin/pisymlink into it), puts thatbinfirst onPATH, and checks that the update command isnpm install -g --prefix <prefix> @earendil-works/pi-coding-agent@latestand that status reportsnpmGlobalwith the version from that prefix.1.2.0is the pi that earlier updates wrote to/opt/homebrew.)provider-maintenance-kit.test.ts: the CLI in a custom prefix gets--prefix, and the npm list probe reads that prefix; a control whereNPM_CONFIG_PREFIXmakes the same prefix npm's default keeps the plain command; a CLI outside any npm package gets no prefix.pnpm exec turbo run test --filter=@bb/provider-bridge-protocol --filter=bb-plugin-provider-pi: 314 and 318 tests pass.pnpm exec turbo run test --filter=bb-plugin-provider-codex --filter=bb-plugin-provider-claude-code --filter=@get-bb/plugin-sdk: all pass.pnpm exec turbo run typecheckfor those five packages: pass.Refs #4009