Skip to content

Commit

Permalink
chore(asdf2devbox): Only update to latest if no previous version is i…
Browse files Browse the repository at this point in the history
…nstalled

# Issue

If a version of a program was not packaged in NixOS, `asdf2devbox` would
update to latest which might increase the version skew.

E.g. Go 1.22.4 is not packaged in NixOS, updating to it would update to
`go@latest` which might be Go 1.23 - in effect a major version upgrade.

# Fix

asdf2devbox does not update if a version was already referenced in
devbox, to minimize version skew.
  • Loading branch information
silvestre committed Sep 25, 2024
1 parent a3f6993 commit ac5b19c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions scripts/asdf2devbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit ac5b19c

Please sign in to comment.