From 0921cd71ec38798888cde43f98ed60a7222e9c6d Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Fri, 26 Jun 2026 12:51:12 +0200 Subject: [PATCH] Kotlin wrapper: keep selected compiler install available after cleanups Why this is needed: - The dev wrapper persisted the selected version in .kotlinc_version, but only installed binaries when the selected version changed. - After a clean working directory (which can remove .kotlinc_installed), the version file can still point at an already-selected compiler, causing forward execution to fail because the binary directory no longer exists. What this changes: - Make install() idempotent by returning early when install dir already exists. - Call install() unconditionally from main() so the selected version is always materialised before forwarding. - Keep explicit reinstall behaviour on version switches by removing the old install directory when selection changes. This is an independent reliability fix and not tied to Kotlin 1.x test routing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- java/kotlin-extractor/dev/wrapper.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/java/kotlin-extractor/dev/wrapper.py b/java/kotlin-extractor/dev/wrapper.py index 34b9d6b9425..052a89e049e 100755 --- a/java/kotlin-extractor/dev/wrapper.py +++ b/java/kotlin-extractor/dev/wrapper.py @@ -75,6 +75,9 @@ def get_version(): def install(version: str, quiet: bool): + if install_dir.exists(): + return + if quiet: info_out = subprocess.DEVNULL info = lambda *args: None @@ -83,8 +86,6 @@ def install(version: str, quiet: bool): info = lambda *args: print(*args, file=sys.stderr) file = file_template.format(version=version) url = url_template.format(version=version) - if install_dir.exists(): - shutil.rmtree(install_dir) install_dir.mkdir() zips_dir.mkdir(exist_ok=True) zip = zips_dir / file @@ -156,8 +157,11 @@ def main(opts, forwarded_opts): selected_version = current_version or DEFAULT_VERSION if selected_version != current_version: # don't print information about install procedure unless explicitly using --select - install(selected_version, quiet=opts.select is None) + if install_dir.exists(): + shutil.rmtree(install_dir) version_file.write_text(selected_version) + # don't print information about install procedure unless explicitly using --select + install(selected_version, quiet=opts.select is None) if opts.select and not forwarded_opts and not opts.version: print(f"selected {selected_version}") return