Skip to content

fix(terminal): prioritize user npm binaries#11

Open
blackmammoth wants to merge 1 commit into
cloudcli-ai:mainfrom
blackmammoth:fix/user-npm-path-priority
Open

fix(terminal): prioritize user npm binaries#11
blackmammoth wants to merge 1 commit into
cloudcli-ai:mainfrom
blackmammoth:fix/user-npm-path-priority

Conversation

@blackmammoth

Copy link
Copy Markdown

Why

Terminal sessions inherit the plugin server’s environment when spawning a PTY.

In packaged or hosted environments, this PATH may place system or bundled
executables before npm binaries installed by the user. Commands can therefore
resolve to an outdated or unintended CLI even when the user has installed a
newer global version.

The plugin terminal should prefer the same user-installed npm tools that would
normally be selected in the user’s local shell.

What Changed

  • Detect the environment’s PATH key case-insensitively.
  • Read npm_config_prefix and APPDATA case-insensitively.
  • Recognize common user npm binary locations:
    • npm_config_prefix
    • <npm_config_prefix>/bin
    • %APPDATA%\npm
    • ~/AppData/Roaming/npm
    • ~/.npm-global/bin
  • Move recognized directories already present in PATH to the front.
  • Preserve every remaining PATH entry and its relative order.
  • Avoid adding directories that were not already configured.
  • Apply the adjusted environment only to newly spawned PTY sessions.
  • Leave process.env unchanged.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant