Skip to content

Commit 24706b2

Browse files
authored
Fixes a regression where not having a system nim crashed the build (#1462)
1 parent 10a8cba commit 24706b2

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/nimblepkg/vnext.nim

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ proc solvePackagesWithSystemNimFallback*(
156156
rootPackage: PackageInfo,
157157
pkgList: seq[PackageInfo],
158158
options: var Options,
159-
resolvedNim: NimResolved): HashSet[PackageInfo] =
159+
resolvedNim: Option[NimResolved]): HashSet[PackageInfo] =
160160
## Solves packages with system Nim as a hard requirement, falling back to
161161
## solving without it if the first attempt fails due to unsatisfiable dependencies.
162162

@@ -167,8 +167,8 @@ proc solvePackagesWithSystemNimFallback*(
167167
# as a hard requirement. If it fails, we will fallback to
168168
# retry without it as a hard requirement. The idea behind it is that a
169169
# compatible version of the packages is used for the current nim.
170-
if resolvedNim.isSystemNim(options):
171-
rootPackageWithSystemNim.requires.add(parseRequires("nim <=" & $resolvedNim.version))
170+
if resolvedNim.isSome and resolvedNim.get.isSystemNim(options):
171+
rootPackageWithSystemNim.requires.add(parseRequires("nim <=" & $resolvedNim.get.version))
172172
systemNimPass = true
173173

174174
result = solvePackages(rootPackageWithSystemNim, pkgList,
@@ -230,8 +230,12 @@ proc resolveNim*(rootPackage: PackageInfo, pkgList: seq[PackageInfo], options: v
230230
# let latestNim = getLatestNimRelease()
231231
# if latestNim.isSome:
232232
# return NimResolved(version: latestNim.get)
233+
var resolvedNim: Option[NimResolved]
234+
if systemNimPkg.isSome:
235+
resolvedNim = some(NimResolved(pkg: systemNimPkg, version: systemNimPkg.get.basicInfo.version))
236+
233237
options.satResult.pkgs = solvePackagesWithSystemNimFallback(
234-
rootPackage, pkgListDecl, options, NimResolved(pkg: some(systemNimPkg.get), version: systemNimPkg.get.basicInfo.version))
238+
rootPackage, pkgListDecl, options, resolvedNim)
235239

236240
if options.satResult.solvedPkgs.len == 0:
237241
displayError(options.satResult.output)
@@ -480,7 +484,7 @@ proc solvePkgsWithVmParserAllowingFallback*(rootPackage: PackageInfo, resolvedNi
480484
options.satResult.pkgList = pkgList.toHashSet()
481485

482486
options.satResult.pkgs = solvePackagesWithSystemNimFallback(
483-
rootPackage, pkgList, options, resolvedNim)
487+
rootPackage, pkgList, options, some(resolvedNim))
484488

485489
if options.satResult.solvedPkgs.len == 0:
486490
displayError(options.satResult.output)

0 commit comments

Comments
 (0)