Skip to content

fix(pi): a registry that fails keeps an installed Pi - #1330

Merged
amiddavid merged 1 commit into
mainfrom
fix/pi-installer-npm-view-keeps-pi
Nov 24, 2026
Merged

amiddavid merged 1 commit into
mainfrom
fix/pi-installer-npm-view-keeps-pi

Conversation

@vz-ibm

@vz-ibm vz-ibm commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Behavior change (edge case), approved by Vitaly Zabershinsky (2026-11-24):

  • Who: a user who runs install-pi.sh with Pi installed, while npm cannot read the registry (for example E401 from a company .npmrc, or a blocked network).
  • Old: the installer stops at the Pi step with npm's message. Nothing is installed.
  • New: the installer shows npm's message, says "Pi stays", and goes on with the package, the connection and the setup.
  • How to turn it off: there is no switch. To update Pi, fix the registry or set CG_PI_NPM_REGISTRY, then run the installer again.
  • With no Pi installed, nothing changes: it stops, and nothing is changed.

Data dependence: none. No change to what the installer reads or stores.

Summary

At the Pi step, the installer asks npm for the latest Pi version before it looks at the installed Pi. When that npm call fails, the whole install stops, even though keeping the installed Pi needs no npm.

What changed

  • pi-package/scripts/install_pi.py: ensure_pi catches the failed npm view. With Pi installed, it keeps that Pi and returns. With no Pi, it stops as before.
  • 2 tests in test_install_pi.py: a failing registry with Pi installed (the install goes on to the package step), and with no Pi (it stops and changes nothing).
  • The design doc and docs/how-to/install-pi-package.md describe the new case.

How it was tested

  • The new test failed before the fix, on the stop message. Now all pi-package/scripts and pi-package/release tests pass.
  • Not tested: a real run against a failing registry.

Technical notes

The OpenCode installer (#1296) has the same rule. Reviewer 1 found the problem there in review round 3.

When npm view fails (E401, a blocked registry) and Pi is installed,
install-pi.sh stopped. Nothing in that case needs npm. The installer
now shows npm's message, keeps that Pi, and goes on. With no Pi, it
still stops and changes nothing.

The OpenCode installer (#1296) does the same; review round 3 there
found it.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (claude, user of @vz-ibm) Claude Code 2.1.325 offload-review skill, @vz-ibm's session fresh 2 of 2 1 of 2 9d9ad16eca1a approve

Verdict: approve

Findings

None.

Non-blocking

  • pi-package/scripts/test_install_pi.py:268: the new test test_a_registry_that_fails_keeps_an_installed_pi_and_goes_on reads code but does not check it. Add self.assertEqual(code, 0). Then the test also proves that the whole install finishes, not only that it gets to the package step.
  • pi-package/scripts/install_pi.py:197-208: when pi is on PATH but pi --version prints text that is not a version, installed is that text. With a failing registry, the installer now keeps that Pi and goes on. With a working registry, the installer offers an update for this case. The later pi calls stop with their own message, so the result is still safe. You can use version_tuple(installed) in the if not installed check to make the two cases the same. This is optional.
  • The removesuffix(' Nothing was changed.') call depends on the exact end of the latest_pi message (line 192). If someone changes that text, the user sees "Nothing was changed." and then the install goes on. The first new test does not check that this text is absent. An assertNotIn("Nothing was changed.", printed) would hold the two in step.

What I checked

  • I read the full diff (4 files, 1 commit) and the commit message.
  • ensure_pi (lines 195-224) and latest_pi (lines 188-193): the Stop is caught only around latest_pi. With no Pi (installed is None or ""), the code raises the same Stop as before. The old behavior for that case does not change.
  • With Pi installed, the method returns before any npm install. No record change: pi_installed is not set, so uninstall does not remove a Pi that the installer did not install.
  • No later step needs npm: install_package, connection, setup and finish use pi, the plugin script and HTTP only.
  • The message keeps npm's stderr and the CG_PI_NPM_REGISTRY hint. The new test checks both.
  • str.removesuffix needs Python 3.9. The file already uses it at line 289, so this adds no new need.
  • The fake shell change (npm_view_error) is used only by the two new tests. The other tests keep the old default.
  • Docs: the how-to and the design doc (step 2 and the failure table) describe the new case. No other doc names the old "registry fails, nothing changed" rule for an installed Pi.
  • Behavior change: the PR names it at the top, with who, old, new and how to turn it off, and a human's yes (Vitaly Zabershinsky, 2026-11-24). I did not check where that yes is recorded outside the PR text.
  • Data dependence: none. The installer reads and stores nothing new.
  • I did not run the tests. Live tests are not approved for this review.

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (claude, user of @vz-ibm) Claude Code 2.1.325 offload-review skill, @vz-ibm's session fresh 1 of 2 1 of 2 9d9ad16eca1a approve

Verdict: approve

Findings

None.

Non-blocking

  • test_install_pi.py:266 — the test test_a_registry_that_fails_keeps_an_installed_pi_and_goes_on sets code and does not use it. The run gives no answers, so it probably stops later at the connection step with code 1. The test proves "goes on" with the pi install count, which is enough. You can write _, terminal = ... to make this clear, as test_current_pi_asks_nothing_about_pi does.
  • install_pi.py:205 — the message depends on the exact suffix " Nothing was changed." in latest_pi. If someone edits that text, the user sees "Nothing was changed." and then the install goes on. The text is correct today. A test assertion such as assertNotIn("Nothing was changed.", printed) in the first new test would guard it.

What I checked

  • I read the full diff (4 files, 1 commit) and the commit message, which has the DCO sign-off and Assisted-By.
  • install_pi.py:195-224 (ensure_pi) and latest_pi (188-193):
    • Pi installed, npm view fails: latest_pi raises Stop. The new except shows npm's stderr and the CG_PI_NPM_REGISTRY hint, shows "Pi stays.", and returns. No npm install runs. record["pi_installed"] stays unset, so uninstall (line 510) does not remove a Pi that the user owned. Correct.
    • No Pi (which is empty, or pi --version gives empty stdout, so installed is ""): the Stop goes up again, and install() returns 1 before any change. The behavior is the same as before.
    • removesuffix(' Nothing was changed.') matches the latest_pi text exactly (space included). The shown text ends at "set CG_PI_NPM_REGISTRY.", so it does not say "Nothing was changed." when the install goes on.
    • ensure_pi has one caller (install, line 165). No other path calls latest_pi.
  • Tests: FakeShell.npm_view_error returns code 1 with stderr for npm view only. Both new tests check the message, that no npm install ran, and if the package step ran or not. They cover the two branches of the new code.
  • Docs: the how-to line and the design doc (step 2 and the failure table) agree with the code. The "Pi stays" text matches the output.
  • PR body: it names the behavior change at the top with who, old, new and how to turn it off, and it records a human's yes (Vitaly Zabershinsky, 2026-11-24). Data dependence: none, which is correct; the change adds no read or write of stored data.
  • Fail open: this is the installer, not the request path. The change makes the installer less strict only when an installed Pi needs no npm.
  • No binary or LFS file in the diff.
  • I did not run the tests. Live tests are not approved, and this review reads the code only.

amiddavid pushed a commit that referenced this pull request Nov 24, 2026
#1326)

fix(pi): the installer names its folders, asks about a moved Pi folder

In a terminal left from a test, PI_CODING_AGENT_DIR and
XDG_STATE_HOME pointed to test folders. The installer used them,
said "Done. Start Pi with: pi", and the user's own Pi was not
routed (#1319). Nothing told the user which folders it used.

- Step 2 names Pi's settings folder and context-guru's data folder.
- When PI_CODING_AGENT_DIR is set, it says so and asks "Use these
  folders? [y/N]" before any change. No stops, and says to open a
  new terminal or unset the variables. Uninstall asks the same, so a
  test-folder install can still be removed.
- The last line names the pi it used, and says to open a new
  terminal if the terminal finds another one (bash caches paths).

Only PI_CODING_AGENT_DIR triggers the question: many Linux users
set the XDG variables on purpose; those folders are named anyway.

Tested: 57 installer tests (5 new). The owner's case in a real pty
with a local release: the folders are named, "n" stops, nothing is
written.

Behavior change: users who run the installer with
PI_CODING_AGENT_DIR set. Old: it used that folder without a word.
New: it asks first; the default is no. To keep the old behavior,
answer y.

Data dependence: none.

Fixes #1319

fix(pi): the review notes on #1326

- PI_CODING_AGENT_DIR that names the default ~/.pi/agent asks no
  question ("in X, not in X" before).
- The stop message says only "open a new terminal": a test can also
  put another pi first on PATH, which `unset` does not undo.
- The last line drops the "(path)" when pi is not on PATH, so it no
  longer says "pi (pi)".
- Tests: main() passes confirm_folders=True; the XDG_STATE_HOME
  text; the default folder; the last line without a path.


Pi behavior change: the PR author (Vitaly) gave his yes on the PR; Pi changes are FYI to the owner (owner rule 2026-11-20). The owner (David Amid, 2026-11-24, integrator session) asked the integrator to merge the Pi set "as you see fit". Integrator check on current main + #1326 + #1330: the Pi unittest suites, the release tests and go test ./pi-package/... pass.

Assisted-By: Claude Opus 5.5
Signed-off-by: Vitaly Zabershinsky <[email protected]>
@amiddavid
amiddavid merged commit 2c8d8b8 into main Nov 24, 2026
10 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 24, 2026
@vz-ibm

vz-ibm commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Behavior change approved (owner): when npm cannot read the registry, the installer keeps the installed Pi and goes on. Posted by my assistant at my request. — Vitaly

amiddavid added a commit that referenced this pull request Nov 24, 2026
chore(plugins): bump the plugin versions for v0.7.8

- Pi package: 0.1.6 -> 0.1.7 (#1326, #1330, #1335, #1342, #1344).
- OpenCode plugin: pinned proxy version v0.7.7 -> v0.7.8.
- Unchanged: Claude Code plugin 0.7.8 (test files only changed since
  v0.7.7), Codex 0.2.14, Bob 0.1.3.


Release owner (David Amid, 2026-11-24, integrator session): cut v0.7.8 now. Version bumps are under the owner standing approval.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants