From 1562c1ea2ca94d8cc35e84dc342d7cf565e3c30c Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Wed, 13 May 2020 07:11:11 -0700 Subject: [PATCH 1/2] fix #12293 findNimStdLibCompileTime should not break with nimble install compiler --- compiler/nimeval.nim | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/compiler/nimeval.nim b/compiler/nimeval.nim index 09d1eb1dacc6b..3070c56009d6b 100644 --- a/compiler/nimeval.nim +++ b/compiler/nimeval.nim @@ -81,6 +81,9 @@ proc findNimStdLib*(): string = ## Returns "" on failure. try: let nimexe = os.findExe("nim") + # this can't work with choosenim shims, refs https://github.com/dom96/choosenim/issues/189 + # it'd need `nim dump --dump.format:json . | jq -r .libpath` + # which we should simplify as `nim dump --key:libpath` if nimexe.len == 0: return "" result = nimexe.splitPath()[0] /../ "lib" if not fileExists(result / "system.nim"): @@ -93,8 +96,8 @@ proc findNimStdLib*(): string = proc findNimStdLibCompileTime*(): string = ## Same as ``findNimStdLib`` but uses source files used at compile time, ## and asserts on error. - const sourcePath = currentSourcePath() - result = sourcePath.parentDir.parentDir / "lib" + const exe = getCurrentCompilerExe() + result = exe.parentDir.parentDir / "lib" doAssert fileExists(result / "system.nim"), "result:" & result proc createInterpreter*(scriptName: string; From c6e95e31d1cbbbe5c8d5164590be9efe1560e3e5 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Sat, 16 May 2020 21:22:41 -0700 Subject: [PATCH 2/2] address comment to unblock PR --- compiler/nimeval.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/nimeval.nim b/compiler/nimeval.nim index 3070c56009d6b..11e899caee975 100644 --- a/compiler/nimeval.nim +++ b/compiler/nimeval.nim @@ -97,7 +97,7 @@ proc findNimStdLibCompileTime*(): string = ## Same as ``findNimStdLib`` but uses source files used at compile time, ## and asserts on error. const exe = getCurrentCompilerExe() - result = exe.parentDir.parentDir / "lib" + result = exe.splitFile.dir.parentDir / "lib" doAssert fileExists(result / "system.nim"), "result:" & result proc createInterpreter*(scriptName: string;