diff --git a/scripts/asdf2devbox.py b/scripts/asdf2devbox.py index 34712f9d95..f11ee30e66 100755 --- a/scripts/asdf2devbox.py +++ b/scripts/asdf2devbox.py @@ -43,9 +43,15 @@ def get_installed_version(package): try: subprocess.run(['devbox', 'add', f"{program}@{version}"], check=True) except subprocess.CalledProcessError: - # Fallback to latest in case the exact version is not available - subprocess.run(['devbox', 'add', f"{program}@latest"], check=True) - print(f"Could not find {program}@{version}, using latest instead:") + # Fallback to latest in case the exact version is not available and there's no previous version installed + if installed_version is None: + print(f"Could not find {program}@{version}, using latest instead") + subprocess.run(['devbox', 'add', f"{program}@latest"], check=True) + else: + # Readd the previously installed version + print(f"Could not find {program}@{version}, readding {program}@{installed_version}") + subprocess.run(['devbox', 'add', f"{program}@{installed_version}"], check=True) + subprocess.run(['devbox', 'info', program], check=True) else: print(f"{program}@{version} is already installed")