Repository navigation
mise shims break POSIX-compliant strategy for checking if something is installed: command -v <bin_name>
#14327
Replies: 1 comment 1 reply
|
Keep command -v, but when the path it finds is a mise shim, ask mise whether that tool actually resolves here. mise which prints the real executable "bypassing shims", and in src/cli/which.rs it exits with an error when the bin isn't active in the current directory ("... is a mise bin however it is not currently active") or isn't a mise bin at all. have() { p=$(command -v "$1") || return 1 case $p in /mise/shims/) mise which "$1" >/dev/null 2>&1 ;; *) return 0 ;; esac } have prettier || echo "prettier not installed" Users without mise never reach the mise which branch, so this works for a mixed user base. One caveat from docs/dev-tools/shims.md: by default an unresolved shim either auto-installs the tool (not_found_auto_install) or falls through to the next executable with the same name on PATH. If a system copy exists later on PATH, the shim would still run it even though have says no. Users who want shims to fail cleanly can set not_found_system_fallback and not_found_auto_install to false. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Recent changes enabled
shimsby default:Unfortunately this breaks the portable, POSIX-compliant strategy for checking if something is installed:
command -v <bin_name>(some cited examples ofcommand -vas preferred strategy 1, 2).This results in scripts that defensively check that tools are installed potentially throwing false positives, since the symlink to the
misebinary exists.This gets more complicated when having to support a mixed user base of
mise-adopters and non-adopters.I'm raising this as a point of discussion to find out if anyone has a good solution/alternative that isn't simply "disable shims", since users will configure their environment as they see fit.
Alternatives I've considered
which,whence, etc. are all impacted the same way.<bin_name> --versionisn't always suitable/available, which is whycommand -vis the de facto solution.All reactions