Skip to content

Commit b521d16

Browse files
authored
Warn missmatch (#1533)
* Warns when there is a missmatch between the tag and the nimble file version * Improves comment
1 parent 22b0764 commit b521d16

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/nimble.nim

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2691,6 +2691,16 @@ proc runVNext*(options: var Options, nimBin: string) {.instrument.} =
26912691
# options.debugSATResult()
26922692
options.satResult.addReverseDeps(options)
26932693

2694+
# Warn about version mismatches for packages in the solution
2695+
# Compare installed version (from directory/tag) with the version in the .nimble file
2696+
for pkgInfo in options.satResult.pkgs:
2697+
try:
2698+
let nimbleFileInfo = extractRequiresInfo(pkgInfo.myPath, options)
2699+
if nimbleFileInfo.version != "" and newVersion(nimbleFileInfo.version) != pkgInfo.basicInfo.version:
2700+
displayWarning(&"Version mismatch for {pkgInfo.basicInfo.name}: installed version is {pkgInfo.basicInfo.version} but .nimble file declares {nimbleFileInfo.version}.", HighPriority)
2701+
except CatchableError:
2702+
discard
2703+
26942704
proc getNimDir(options: var Options, nimBin: string): string =
26952705
## returns the nim directory prioritizing the nimBin one if it satisfais the requirement of the project
26962706
## otherwise it returns the major version of the nim installed packages that satisfies the requirement of the project

src/nimblepkg/vnext.nim

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -665,12 +665,11 @@ proc installFromDirDownloadInfo(nimBin: string,downloadDir: string, url: string,
665665
var depsOptions = options
666666
depsOptions.depsOnly = false
667667

668-
# Check for version mismatch between tag and .nimble file
669-
# If SAT solver expects a specific version but .nimble has different version,
670-
# the package maintainer likely forgot to update their .nimble file
671-
# TODO in a subsequent PR this will improved so we keep track of the mismatch in PkgInfo
668+
# Check for version mismatch between git tag and .nimble file
669+
# pv.ver.ver is the version from the SAT solver, which was discovered from git tags
670+
# (e.g., tag v0.36.0 -> version 0.36.0). If the .nimble file declares a different
671+
# version (e.g., 0.1.0), we use the tag version since that's what was requested.
672672
if pv.ver.kind == verEq and pkgInfo.basicInfo.version != pv.ver.ver:
673-
displayWarning(&"Version mismatch for {pkgInfo.basicInfo.name}: tag has {pv.ver.ver} but .nimble file has {pkgInfo.basicInfo.version}. Using tag version.", HighPriority)
674673
pkgInfo.basicInfo.version = pv.ver.ver
675674

676675
display("Installing", "$1@$2" %

0 commit comments

Comments
 (0)