Skip to content

installers: detect shadowing dcd and auto-persist PATH on Unix#20

Merged
riglar merged 1 commit into
devfrom
installer-conflict-detection
Jun 19, 2026
Merged

installers: detect shadowing dcd and auto-persist PATH on Unix#20
riglar merged 1 commit into
devfrom
installer-conflict-detection

Conversation

@riglar

@riglar riglar commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Problem

The binary installers (install.sh, install.ps1) never remove a prior npm install -g @devicecloud.dev/dcd, so the two coexist and PATH order decides which dcd actually runs:

  • macOS/Linuxinstall.sh only printed the export PATH=... hint; users who skipped it got "command not found" in the next shell, or kept running the shadowed npm copy.
  • Windowsinstall.ps1 appends .dcd\bin to 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 upgrade give the wrong advice, since the CLI picks its identity from the runtime (process.versions.bun ⇒ binary, else npm).

Changes

install.sh

  • Auto-appends the PATH line to the shell rc (~/.zshrc honoring $ZDOTDIR, ~/.bashrc~/.bash_profile, or ~/.profile per $SHELL), de-duped on re-install, with the manual hint as a fallback if the write fails.
  • Scans $PATH for a dcd outside the install dir and warns to npm uninstall -g @devicecloud.dev/dcd. Runs in a subshell so the temporary IFS=: never leaks.

install.ps1

  • Warns via Get-Command dcd -All when a different dcd is 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.ps1 to prepend would make the binary win automatically — happy to add if preferred.

Testing

  • sh -n install.sh passes.
  • Exercised the conflict-detection helper across npm-only / ours-only / both-present — all correct under POSIX sh. (Note: the local Bash tool runs zsh, which doesn't word-split $PATH on IFS; the installer's #!/usr/bin/env sh shebang + curl | sh invocation is the path that matters, verified under sh.)

🤖 Generated with Claude Code

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>
@claude

claude Bot commented Jun 19, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@riglar riglar merged commit a28e911 into dev Jun 19, 2026
2 checks passed
@riglar riglar deleted the installer-conflict-detection branch June 19, 2026 12:45
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