Skip to content

fix(install): replace the flashduty already on PATH by default - #233

Merged
ysyneu merged 1 commit into
mainfrom
fix/install-replaces-existing-binary
Oct 16, 2026
Merged

ysyneu merged 1 commit into
mainfrom
fix/install-replaces-existing-binary

Conversation

@ysyneu

@ysyneu ysyneu commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Problem

Without FLASHDUTY_INSTALL_DIR, install.sh always installs to /usr/local/bin. If the flashduty the shell runs lives elsewhere (~/.local/bin from the installer's own non-interactive fallback, ~/go/bin from go install, …), an upgrade drops a second copy into /usr/local/bin that the earlier PATH entry keeps shadowing:

$ flashduty update
...
[flashduty] Installed to /usr/local/bin/flashduty
Update complete. Run 'flashduty version' to verify.
$ flashduty version
flashduty version 1.5.10 ...

flashduty update in v1.5.11+ passes the running binary's location, but releases up to v1.5.10 do not, and they fetch the latest install.sh from the CDN — so fixing the installer also repairs their next update. Re-running the documented curl … | sh hits the same problem on any version.

Change

  • Default the install directory to that of the flashduty ($INSTALLED_NAME) found on PATH; fresh installs still use /usr/local/bin. Explicit FLASHDUTY_INSTALL_DIR is unchanged.
  • After installing, warn when the shell still resolves a different copy (replaces the "not in PATH" check, which it subsumes). Directories are compared so dash's <dir>//flashduty output for trailing-slash PATH entries doesn't false-alarm.
  • Refuse when FLASHDUTY_MANAGED_BY_RUNNER=1, matching flashduty update: flashduty-runner ships its own copy.
  • README / README_zh default updated.

Tests

New cases in tests/install_sh_sudo_test.sh: replaces the copy on PATH (with a trailing-slash PATH entry), warns when a non-writable copy on PATH shadows the fallback install, refuses under the runner flag. All three fail against the previous install.sh and pass now.

  • ubuntu:24.04 (/bin/sh = dash): shellcheck + full test script pass.
  • macOS arm64, end to end against the real CDN: a v1.5.10 binary first on PATH, no FLASHDUTY_INSTALL_DIR → replaced in place, flashduty version reports 1.5.22, nothing written to /usr/local/bin or ~/.local/bin; with FLASHDUTY_MANAGED_BY_RUNNER=1 → exits 1 before downloading.

Rollout note

The install-scripts workflow mirrors install.sh to the CDN on merge to main, and the CDN caches it, so the cache for flashduty-cli/install.sh needs a refresh after merge. Windows install.ps1 is unchanged.

Without FLASHDUTY_INSTALL_DIR the installer always targeted /usr/local/bin.
When the active flashduty lives elsewhere (for example ~/.local/bin from
the installer's own non-interactive fallback, or ~/go/bin), an upgrade
installed a second copy that the earlier PATH entry kept shadowing, so
`flashduty version` still reported the old release. `flashduty update`
from releases before v1.5.11 hits the same path, since those releases do
not pass the running binary's location to the installer.

- Default the install directory to that of the flashduty found on PATH,
  falling back to /usr/local/bin for fresh installs.
- After installing, warn when the shell still resolves a different copy.
  Directories are compared, so dash's "<dir>//flashduty" output for a
  trailing-slash PATH entry does not raise a false warning.
- Refuse to run when FLASHDUTY_MANAGED_BY_RUNNER=1, matching
  `flashduty update`: flashduty-runner ships and verifies its own copy.
@ysyneu
ysyneu merged commit 6cf6614 into main Oct 16, 2026
15 checks passed
@ysyneu
ysyneu deleted the fix/install-replaces-existing-binary branch October 16, 2026 03:30
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