diff --git a/CHANGELOG.md b/CHANGELOG.md index 14fd67b0..1c2f1631 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Not released yet +### Fixes + +* Fix installer to better handle invalid --install-dir option + ## 1.3.0 (2026-03-06) ### Features @@ -21,7 +25,7 @@ * Add a `terminal()` function to get terminal properties * Add a `#[AsArgsAfterOptionEnd]` attribute to get all arguments after `--` delimiter -### Fixed +### Fixes * Do not generate stub if no castor file, also check for completion command name diff --git a/installer/bash-installer b/installer/bash-installer index fece4d23..d652b9cf 100755 --- a/installer/bash-installer +++ b/installer/bash-installer @@ -200,8 +200,22 @@ if [ $http_code != 200 ]; then exit 1 fi +if [ ! -d "${binary_dest}" ]; then + # Backward-compatible quick fix: if --install-dir points to the castor binary path, + # install into its parent directory. + # There was a bug fixed in https://github.com/jolicode/castor/pull/786 + if [ "$(basename "${binary_dest}")" = "${CASTOR_EXECUTABLE}" ]; then + binary_dest="$(dirname "${binary_dest}")" + fi +fi + if [ ! -d "${binary_dest}" ]; then if ! mkdir -p "${binary_dest}"; then + if [ "${custom_dir}" = "true" ]; then + output "[castor-installer] Error: invalid value for --install-dir: '${binary_dest}'. Expected a directory, or a full path ending with '/${CASTOR_EXECUTABLE}'." "error" + exit 1 + fi + binary_dest="." fi fi