From caec5789857891d9a5b3aaf82635a584aa3f73a1 Mon Sep 17 00:00:00 2001 From: nessi Date: Wed, 18 Mar 2026 10:56:58 +0100 Subject: [PATCH] refactor: add PATH search logic to cargo-xwin wrapper script to find real binary outside script directory Replace direct cargo xwin execution with PATH traversal to locate actual cargo-xwin binary outside script's own directory. Add error handling with installation instructions when binary not found. Skip script's own directory and empty PATH entries during search. --- desktop-client/scripts/cargo-xwin | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/desktop-client/scripts/cargo-xwin b/desktop-client/scripts/cargo-xwin index 0640353..eb6f1c0 100644 --- a/desktop-client/scripts/cargo-xwin +++ b/desktop-client/scripts/cargo-xwin @@ -9,4 +9,27 @@ if ! command -v clang-cl >/dev/null 2>&1; then exit 1 fi -exec cargo xwin "$@" +SELF_DIR="$(cd "$(dirname "$0")" && pwd)" +REAL_CARGO_XWIN="" + +IFS=':' +for dir in ${PATH}; do + if [ -z "${dir}" ] || [ "${dir}" = "${SELF_DIR}" ]; then + continue + fi + + if [ -x "${dir}/cargo-xwin" ]; then + REAL_CARGO_XWIN="${dir}/cargo-xwin" + break + fi +done +unset IFS + +if [ -z "${REAL_CARGO_XWIN}" ]; then + echo "cargo-xwin binary was not found outside ${SELF_DIR}." + echo "Install it with:" + echo " cargo install --locked cargo-xwin" + exit 1 +fi + +exec "${REAL_CARGO_XWIN}" "$@"