Skip to content

"upgrade pi and packages" button trow error when pi already exist #15

Open

Description

@napa3um
npm install --global @mariozechner/pi-coding-agent@latest && /usr/local/share/nvm/versions/node/v26.3.0/bin/pi update
vscode ➜ /workspaces/wai $ npm install --global @mariozechner/pi-coding-agent@latest && /usr/local/share/nvm/versions/node/v26.3.0/bin/pi update
npm warn deprecated node-domexception@1.0.0: Use your platform's native DOMException instead
npm warn deprecated @mariozechner/pi-agent-core@0.73.1: please use @earendil-works/pi-agent-core instead going forward
npm warn deprecated @mariozechner/pi-tui@0.73.1: please use @earendil-works/pi-tui instead going forward
npm warn deprecated @mariozechner/pi-ai@0.73.1: please use @earendil-works/pi-ai instead going forward
npm error code EEXIST
npm error path /usr/local/share/nvm/versions/node/v26.3.0/bin/pi
npm error EEXIST: file already exists
npm error File exists: /usr/local/share/nvm/versions/node/v26.3.0/bin/pi
npm error Remove the existing file and try again, or run npm
npm error with --force to overwrite files recklessly.
npm error A complete log of this run can be found in: /home/vscode/.npm/_logs/2026-06-03T22_50_40_904Z-debug-0.log

pi already exists by "feature" item "ghcr.io/RodriBus/devcontainer-features/pi-coding-agent:0" in devcontainer.json

Activity

  1. napa3um commented on Jun 3, 2026

    @napa3um
    Author

    and why does the button try to install @mariozechner/pi-coding-agent and not @earendil-works/pi-coding-agent? 🤔

  2. napa3um commented on Jun 3, 2026

    @napa3um
    Author
    Image
  3. Hmenez3s commented on Jul 18, 2026

    @Hmenez3s

    I can reproduce a more severe variant of the same root problem on Windows/NVM: the upgrade action can replace a working Earendil PI installation and make installed extensions crash on the next startup.

    Reproduction

    1. Run a working installation based on @earendil-works/pi-coding-agent with pi-xai-oauth enabled.
    2. Use Upgrade Pi and Packages in pi-vscode 0.0.9.
    3. Reload VS Code.
    4. PI fails while loading pi-xai-oauth, with a missing-module path ending in @earendil-works/pi-ai/dist/index.js/compat.

    Root cause

    src/upgrade.ts hardcodes:

    export const PI_PACKAGE_NAME = "@mariozechner/pi-coding-agent";

    Therefore the action runs approximately:

    npm install --global @mariozechner/pi-coding-agent@latest && <resolved-pi> update
    

    This does not upgrade the package that owns the resolved binary when the user installed the maintained Earendil fork. It replaces/mixes package families before pi update loads installed packages.

    The failure is not caused by compat.js being absent from current Earendil PI:

    • @earendil-works/pi-ai@0.80.10 contains dist/compat.js and exports ./compat.
    • @earendil-works/pi-coding-agent@0.80.10 aliases @earendil-works/pi-ai/compat in its extension loader.
    • pi-xai-oauth@1.3.6 declares peers >=0.80.1 <0.81.0 and its official loader check passes against exact PI 0.80.10 on Node 22.19.0.

    The mixed loader/package family causes the @earendil-works/pi-ai/compat subpath to be resolved incorrectly, producing the observed startup crash before package update/recovery can complete.

    Expected behavior

    The extension should discover the package that actually owns the resolved pi binary and upgrade that same package. At minimum, it should show the package name before confirmation and refuse to replace a different distribution/fork.

    A robust approach would be:

    1. Resolve the real pi path.
    2. Find its owning package.json and read name/version.
    3. Upgrade that exact package with the inferred package manager.
    4. Run pi update only after the CLI upgrade succeeds.
    5. Never hardcode a different package family.

    I also verified the recovery approach in a local installer without publishing private repository details.

    One additional environment note: current Earendil PI 0.80.10 declares Node >=22.19.0; the affected Windows report used Node 22.12.0, which should also be upgraded, although it does not explain the hardcoded package replacement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions