installers: detect shadowing dcd and auto-persist PATH on Unix#20
Merged
Conversation
A prior `npm install -g @devicecloud.dev/dcd` is never removed by the binary installers, so the two coexist and PATH order decides the winner. On Windows the appended install dir loses to npm's earlier bin entry, silently shadowing the freshly installed binary. - install.sh: scan PATH for a dcd outside the install dir and warn to `npm uninstall -g`; auto-append the PATH line to the shell rc (zsh/bash/profile), de-duped on re-install, with the manual hint as a fallback. - install.ps1: warn via Get-Command when a different dcd is already on PATH (the registry change isn't visible in-session, so any hit is a pre-existing install). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
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.
Problem
The binary installers (
install.sh,install.ps1) never remove a priornpm install -g @devicecloud.dev/dcd, so the two coexist and PATH order decides whichdcdactually runs:install.shonly printed theexport PATH=...hint; users who skipped it got "command not found" in the next shell, or kept running the shadowed npm copy.install.ps1appends.dcd\binto PATH, which resolves after npm's%APPDATA%\npm, so the freshly installed binary is silently shadowed by the old npm version.A shadowed install also makes
dcd upgradegive the wrong advice, since the CLI picks its identity from the runtime (process.versions.bun⇒ binary, else npm).Changes
install.sh~/.zshrchonoring$ZDOTDIR,~/.bashrc→~/.bash_profile, or~/.profileper$SHELL), de-duped on re-install, with the manual hint as a fallback if the write fails.$PATHfor adcdoutside the install dir and warns tonpm uninstall -g @devicecloud.dev/dcd. Runs in a subshell so the temporaryIFS=:never leaks.install.ps1Get-Command dcd -Allwhen a differentdcdis already on PATH. The registry PATH change isn't visible in-session, so any hit is genuinely a pre-existing install (the npm copy).Not in scope
Windows still appends to PATH, so the npm copy keeps winning until uninstalled (the new warning tells the user to do so). Switching
install.ps1to prepend would make the binary win automatically — happy to add if preferred.Testing
sh -n install.shpasses.sh. (Note: the local Bash tool runs zsh, which doesn't word-split$PATHonIFS; the installer's#!/usr/bin/env shshebang +curl | shinvocation is the path that matters, verified undersh.)🤖 Generated with Claude Code