From 29fcef3b9c8cce6f90d9ced2561a9f99ba859921 Mon Sep 17 00:00:00 2001 From: Orkuncakilkaya Date: Sat, 5 Sep 2026 22:16:16 +0300 Subject: [PATCH] fix(cli): report the installed version, not the current directory's MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `ludic version` looked for bin/ludicc and VERSION relative to the working directory. In the toolchain repo that is right by accident; from a project — the only place a user runs it — there is no ./bin, so a perfectly good install answered "(version unknown)". It now resolves the compiler through ludic_home(), like every other command. The regression test asked for the version from the repo root, so it passed for the same accidental reason the bug hid behind; it now asks from the staged project, where the answer can only come from the install. Co-Authored-By: Claude Opus 5 --- changes/version-from-install-root.md | 6 ++++++ tools/ludic-cli/release.ludic | 16 ++++++++++++---- tools/ludic-cli/test.ludic | 5 ++++- 3 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 changes/version-from-install-root.md diff --git a/changes/version-from-install-root.md b/changes/version-from-install-root.md new file mode 100644 index 00000000..7076d1ca --- /dev/null +++ b/changes/version-from-install-root.md @@ -0,0 +1,6 @@ +bump: patch +type: fix +`ludic version` reports the version of the toolchain it belongs to. It looked for +`bin/ludicc` and `VERSION` beside the *current* directory, so it answered +"(version unknown)" from a project — which is the only place a user ever runs it. +It now resolves the compiler through the install root, like every other command. diff --git a/tools/ludic-cli/release.ludic b/tools/ludic-cli/release.ludic index a88ca252..091b6de5 100644 --- a/tools/ludic-cli/release.ludic +++ b/tools/ludic-cli/release.ludic @@ -49,13 +49,21 @@ function compute_next(cur: pointer, level: pointer) -> pointer { return `{maj}.{min}.{p2}` } -# ludic version — report the toolchain version. Prefer the compiler's own --version -# (proving that path works); fall back to the file if ludicc is not built yet. +# ludic version — report the version of the toolchain this CLI belongs to. +# +# It asks the compiler (proving that path works), addressed through ludic_home() +# rather than as a relative bin/ludicc: `ludic version` is run from a user's +# project, not from the toolchain's own directory, and looking beside the current +# directory found nothing there and reported "(version unknown)" for a perfectly +# good install. function cmd_version() -> int { - if is_exec("bin/ludicc") { - run("LUDIC_HOME=. bin/ludicc --version") + let cc = ludicc() + if is_exec(cc) { + run(`{cc} --version`) return 0 } + let v = read_file(`{ludic_home()}VERSION`) + if v != null { print(`ludic {s_trim(v)}`); return 0 } print(`ludic {read_version_or("(version unknown)")}`) return 0 } diff --git a/tools/ludic-cli/test.ludic b/tools/ludic-cli/test.ludic index 2665ab30..39fd24d4 100644 --- a/tools/ludic-cli/test.ludic +++ b/tools/ludic-cli/test.ludic @@ -84,7 +84,10 @@ function install_layout_case() -> void { if not shq(`cd {work}/demo && {envp} ludic test > {work}/test.out 2>&1`) { bad2(lbl, capture_line(`tail -1 {work}/test.out`)); return } - let ver = capture_line(`{envp} ludic version`) + # from the project directory, never the repo root: `ludic version` used to + # answer from a ./bin and ./VERSION next to the *current* directory, which made + # this check pass in the repo while a real install said "(version unknown)". + let ver = capture_line(`cd {work}/demo && {envp} ludic version`) if ver != `ludic {s_trim(read_file("VERSION"))}` { bad2("an installed `ludic version` reports the install's VERSION", `got [{ver}]`); return }