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 4445e67 commit 9edf5ee
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions scripts/asdf2devbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ 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:")
subprocess.run(['devbox', 'info', program], check=True)
# 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)
subprocess.run(['devbox', 'info', program], check=True)
else:
print(f"{program}@{version} is already installed")

0 comments on commit 9edf5ee

Please sign in to comment.