Fixing “pi: Command Not Found” After Migrating pi to a Managed Installation

After the migration script reports success, typing pi still throws CommandNotFoundException. The cause is that the install directory C:\Users\reanod\.pi\agent\bin never made it into your current terminal’s PATH. Below is the full walkthrough — why pi update asks you to migrate, what the installer actually does, and how to fix the PATH so pi resolves correctly.

Why pi update Tells You to Migrate to a Managed Installation

When you run pi update in PowerShell, you see this warning:

This npm installation of pi does not pin its dependencies.
Run the installer to migrate to a managed installation that does:

  powershell -c "irm https://pi.dev/install.ps1 | iex"

It means your pi was installed with npm install -g @earendil-works/pi-coding-agent, and its underlying dependencies are not version-locked. pi pulls in a set of transitive dependencies, and a global npm install does not pin their versions. The next install or update can grab newer, incompatible versions, which may break pi or its extensions at runtime. A managed installation pins every dependency to a known version during setup. After that, you update through pi update and get the same environment every time.

The two install modes compare like this:

Feature Managed installation npm global install
Dependency versions Pinned Not pinned
Update method pi update pi update works, but transitive deps can drift
Install location ~/.pi/agent/bin nvm’s nodejs directory

The official recommendation is to migrate to a managed installation. The trade-off is that setup takes longer because dependencies are re-downloaded and the old package is uninstalled.

What the Three Migration Options Actually Do

After you run the installer, it detects the existing npm install and drops you into an interactive prompt:

Pi is already installed at:
  C:\nvm4w\nodejs\pi.ps1

Migration:
  Pi will install to C:\Users\reanod\.pi\agent\bin\pi.cmd, then remove the npm package:
  npm.cmd uninstall -g @earendil-works/pi-coding-agent

Choose an action:
  y    Migrate Pi to a managed installation (default)
  u    Uninstall Pi
  n    Do nothing

y is the default and runs the migration. The script first installs the managed build to C:\Users\reanod\.pi\agent\bin\pi.cmd, then runs npm.cmd uninstall -g @earendil-works/pi-coding-agent to remove the old global package. This sequence matters — leaving both installs on the machine means two pi binaries competing for the same PATH entry. u uninstalls without installing anything, and n keeps your current npm install as-is.

Choosing y prints a wait message:

Will migrate Pi to a managed installation.
This will take a while. We're sorry.

During this phase the installer downloads dependencies and writes to the new directory. Do not close the window or press Ctrl+C — an interrupted migration can leave a half-installed state. When it finishes, you see ok install complete along with confirmation that the migration succeeded and a note to use pi update going forward.

Why pi Still Fails Right After a Successful Migration

The installer’s last question is:

Pi was installed, but your shell is not using that install yet.
Add C:\Users\reanod\.pi\agent\bin to your user PATH now? [Y/n]:

Even if you answer Y, your already-open terminal will not see the change. Windows environment variable modifications do not propagate to running processes — only new windows read the updated value. So if you type pi in the same window right after migration, you will most likely see:

pi : The term 'pi' is not recognized as the name of a cmdlet, function, script file, or operable program.

To confirm what your current session actually has:

$env:PATH -split ';' | Select-String "pi"

If the only match is something like F:\python_workspace\Batch_irregular_grasping\.venv/Scripts, that is a false positive — your project path happens to contain the substring pi. The real target, C:\Users\reanod\.pi\agent\bin, is absent, confirming the current terminal never loaded the new path.

Adding pi to Your User PATH and Verifying It Works

First confirm the binary actually landed on disk:

Test-Path C:\Users\reanod\.pi\agent\bin\pi.cmd

If this returns False, the migration did not write successfully and you should re-run the installer. If it returns True, proceed with the PATH fix.

Add the directory to your user-level PATH from the command line:

$userPath = [Environment]::GetEnvironmentVariable("Path", "User")

if ($userPath -notlike "*C:\Users\reanod\.pi\agent\bin*") {
    [Environment]::SetEnvironmentVariable("Path", "$userPath;C:\Users\reanod\.pi\agent\bin", "User")
    "Added to user PATH"
} else {
    "Already present in user PATH, skipping"
}

If you prefer the GUI, press Win + R, type sysdm.cpl, and go to Advanced → Environment Variables. Select Path under User variables, click Edit → New, paste C:\Users\reanod\.pi\agent\bin, and confirm through the dialogs.

Close every open PowerShell and terminal window, then open a fresh one. Old windows will not reload PATH. In the new window:

where.exe pi
pi --version

where.exe pi should output C:\Users\reanod\.pi\agent\bin\pi.cmd, and pi --version should print the version number (around 1.3.0 after migration). If where.exe finds the right path but pi still errors, check the user PATH for stale entries pointing at C:\nvm4w\nodejs and remove them.

For a quick test without touching environment variables, prepend the path in the current session only:

$env:PATH = "C:\Users\reanod\.pi\agent\bin;$env:PATH"
pi --version

This lasts only as long as the window stays open — useful for verifying the install itself is fine before committing to a permanent PATH change.

Checklist

  1. Run powershell -c "irm https://pi.dev/install.ps1 | iex" and choose y at the prompt
  2. Wait for ok install complete and confirm the old npm package was removed
  3. Run Test-Path C:\Users\reanod\.pi\agent\bin\pi.cmd to confirm the binary exists
  4. Add C:\Users\reanod\.pi\agent\bin to your user PATH via command line or the GUI
  5. Close all terminal windows and open a new one
  6. Verify with where.exe pi and pi --version
  7. Update via pi update going forward; use pi update --extensions to include extensions

FAQ

Is the old npm package still installed after migration?

The migration script runs npm.cmd uninstall -g @earendil-works/pi-coding-agent as part of the process, so it should be gone. If where.exe pi still lists a path under the nvm directory, the uninstall did not complete cleanly — remove the corresponding entry from your user PATH manually.

I chose Y to add PATH, but the current window still can’t find pi. Why?

Windows environment variable changes do not apply to already-running terminals. The current process read the old PATH when it started. Open a new terminal window to pick up the updated value.

Select-String "pi" matched .venv/Scripts — is that where pi is installed?

No. Select-String does substring matching, and your project path contains the letters pi. To determine whether pi is actually on PATH, look for the full segment .pi\agent\bin.

Can a managed install and an npm install coexist?

Yes, but whichever comes first in PATH wins, which leads to version confusion. The migration script installs the managed version first and then uninstalls the npm version specifically to avoid this situation.

What command do I use to update pi now?

With a managed installation, run pi update. To also update installed extensions, use pi update --extensions or pi update --all.

where.exe pi returns a result but pi still errors. What should I check?

Confirm the output path is C:\Users\reanod\.pi\agent\bin\pi.cmd. If it points to the nvm directory instead, a stale PATH entry is taking precedence — remove the old entry and reopen the terminal.

What happens if I close the window during migration?

You may end up with partially installed dependencies or both versions present. Re-run the installer and choose y again; the script generally handles overwriting.