Skip to content

Fix Nix version parsing for prereleases that omit the patch component#2872

Open
mikeland73 wants to merge 3 commits into
mainfrom
claude/focused-goldberg-dt2pv1
Open

Fix Nix version parsing for prereleases that omit the patch component#2872
mikeland73 wants to merge 3 commits into
mainfrom
claude/focused-goldberg-dt2pv1

Conversation

@mikeland73

Copy link
Copy Markdown
Collaborator

Summary

Fixes #2766.

Modern Nix prerelease versions report a version string that omits the patch component, e.g. nix (Nix) 2.33pre20251107_479b6b73 (2.33 rather than 2.33.0). Devbox's versionRegexp required a MAJOR.MINOR.PATCH core, so these versions failed to parse. As a result Info.Version came back empty and EnsureNixInstalled aborted with:

Error: Devbox requires nix of version >= 2.12.0. Your version is . Please upgrade nix and try again.

even though the installed Nix was perfectly recent enough.

Changes

  • versionRegexp: make the patch component optional so 2.33pre20251107_479b6b73 parses and Info.Version is populated correctly.
  • Info.AtLeast: when coercing a patch-less Nix prerelease to a valid semver for comparison, inject a .0 patch (2.33-pre.20251107+479b6b732.33.0-pre.20251107+479b6b73), since golang.org/x/mod/semver requires a patch component when a prerelease is present. A new missingPatchRegexp handles this.
  • Added test coverage in nix/nix_test.go for both parsing and AtLeast comparisons of the patch-less prerelease format.

Testing

go test ./nix/
go vet ./nix/

Both pass.

cc @Electrenator (issue reporter)


Generated by Claude Code

Modern Nix prerelease versions such as 2.33pre20251107_479b6b73 omit the
patch component (2.33 rather than 2.33.0). versionRegexp required a patch
component, so these versions failed to parse and EnsureNixInstalled
reported an empty version ("Your version is ."), refusing to run.

Make the patch component optional in versionRegexp and inject a ".0"
patch when coercing such prereleases to a valid semver in Info.AtLeast.

Fixes #2766
Copilot AI review requested due to automatic review settings June 16, 2026 14:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Devbox’s Nix version detection for prerelease version strings that omit the patch component (e.g. 2.33pre20251107_479b6b73), ensuring Info.Version is populated and EnsureNixInstalled no longer fails version checks incorrectly.

Changes:

  • Updated versionRegexp to allow parsing MAJOR.MINOR prerelease forms (optional patch component).
  • Updated Info.AtLeast to coerce patch-less versions into valid semver by inserting a .0 patch before comparing.
  • Added tests covering parsing and comparisons for the patch-less prerelease format.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
nix/nix.go Expands Nix version parsing and semver comparison to handle prereleases missing the patch component.
nix/nix_test.go Adds regression tests for parsing and AtLeast comparisons for patch-less prerelease versions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread nix/nix.go Outdated
claude added 2 commits June 16, 2026 14:12
Address review feedback: semver always requires MAJOR.MINOR.PATCH, so
reword the comment to make clear the .0 insertion works around
golang.org/x/mod/semver's parsing requirement.
The previous run's Elixir example test failed on a transient network
error downloading Hex from builds.hex.pm (TLS handshake), unrelated to
this change.

Copy link
Copy Markdown
Collaborator Author

Heads-up on CI: the only failing check (test … project-tests-only) fails solely on the Elixir example (development_elixir_elixir_hello_run_test), and the failure is unrelated to this change:

** (Mix) httpc request failed with: {:failed_connect, [{:to_address, {~c"builds.hex.pm", 443}}, ...
   {:tls_alert, {:unsupported_certificate, ... key_usage_mismatch ...}}]}
Could not install Hex because Mix could not download metadata at https://builds.hex.pm/installs/hex-1.x.csv

Mix/Erlang is rejecting builds.hex.pm's TLS certificate (server-auth vs keyCertSign/cRLSign key-usage mismatch). All other example tests and the unit tests pass, and this reproduced identically across two runs — so it's an external infra issue affecting main and every PR equally, not something in this diff. This PR only touches nix/nix.go version parsing (covered by the passing go test ./nix/).


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Devbox unable to detect version

3 participants