fix(install): don't clobber an npm-managed CLI during --agents upgrade - #1039
Merged
Conversation
With an outdated npm install on PATH, `command -v railway` is a symlink into <prefix>/lib/node_modules/@railway/cli/bin/railway.js, so EXISTING_BIN_DIR became npm's bin dir and install.sh extracted a raw binary over npm's symlink. npm still records the package as its own, so a later `npm uninstall -g @railway/cli` deletes the binary install.sh just installed, leaving no railway at all. Detect npm-owned installs and mirror the existing Homebrew branch: warn, point at `npm install -g @railway/cli@latest`, and continue agent setup with the CLI that is already there. Refuse early for --remote, which needs a newer CLI. Verified: npm symlink left intact and no ~/.railway/bin created; --remote refuses with exit 1; non-npm installs still upgrade in place. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
pnpm's global bin entry is a /bin/sh shim, not a symlink into node_modules, so the node_modules/.js checks alone missed it. Every release we publish is a native executable, so treat any `railway` on PATH that starts with a shebang as someone else's wrapper — which covers pnpm, and hand-rolled wrappers we equally should not overwrite. Verified: npm, pnpm, yarn and bun are all detected, and a real ELF/Mach-O install is not. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
With an outdated npm install on PATH,
command -v railwayis a symlink into<prefix>/lib/node_modules/@railway/cli/bin/railway.js, soEXISTING_BIN_DIRbecame npm's bin dir and install.sh extracted a raw binary over npm's symlink.npm still records the package as its own, so a later
npm uninstall -g @railway/clideletes the binary install.sh just installed — leaving norailwayat all.npm install -greverts it the other way.Mirrors the existing Homebrew branch: detect npm-owned installs, warn, point at
npm install -g @railway/cli@latest, and continue agent setup with the CLI already present. Refuse early for--remote, which needs a newer CLI.Addresses suggested fix 4 in #990.
Verification
~/.railway/bincreated--remote+ npm: refuses with exit 1🤖 Generated with Claude Code