From c3cf9ac0065ba2dc6ddd3c80f0d63efa72b21357 Mon Sep 17 00:00:00 2001 From: stubbsta Date: Thu, 21 May 2026 14:24:51 +0200 Subject: [PATCH] fix path check in install-nim --- scripts/install_nim.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts/install_nim.sh b/scripts/install_nim.sh index ce71c0345..42aa88ecd 100755 --- a/scripts/install_nim.sh +++ b/scripts/install_nim.sh @@ -19,9 +19,18 @@ fi NIM_DEST="${HOME}/.nim/nim-${NIM_VERSION}" -# Check if nim is already installed at our expected location (not just anywhere in PATH). -# Checking PATH version is not sufficient: a system-installed nim of the right version -# won't have its stdlib at ${NIM_DEST}/lib/, causing downstream compilation failures. +# 1. A matching Nim is already on PATH (e.g. provided by CI's setup-nim-action, +# choosenim, or a previous run of this script). Use it as-is: installing over it +# would symlink a freshly downloaded Nim into ~/.nimble/bin (first on PATH) and +# shadow a known-good toolchain, which has caused C-backend build failures. +nim_ver=$(nim --version 2>/dev/null | head -1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || true) +if [ "${nim_ver}" = "${NIM_VERSION}" ]; then + echo "Nim ${NIM_VERSION} already on PATH ($(command -v nim)), skipping install." + exit 0 +fi + +# 2. Already installed at our expected location from a previous run, but not on PATH. +# Re-link binaries into ~/.nimble/bin. if [ -f "${NIM_DEST}/lib/system.nim" ]; then echo "Nim ${NIM_VERSION} already installed at ${NIM_DEST}, re-linking binaries." mkdir -p "${HOME}/.nimble/bin" @@ -31,8 +40,7 @@ if [ -f "${NIM_DEST}/lib/system.nim" ]; then exit 0 fi -nim_ver=$(nim --version 2>/dev/null | head -1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || true) -if [ -n "${nim_ver}" ] && [ "${nim_ver}" != "${NIM_VERSION}" ]; then +if [ -n "${nim_ver}" ]; then echo "INFO: Nim ${nim_ver} found in PATH; installing Nim ${NIM_VERSION} to ${NIM_DEST}." >&2 fi