diff --git a/readme.markdown b/readme.markdown index 5a8cb99..9bc6dbe 100644 --- a/readme.markdown +++ b/readme.markdown @@ -773,6 +773,13 @@ installation. Make sure that you are running at least version 0.16.0 of Nim (or the latest nightly). +* ``Error: cannot open '/home/user/.nimble/lib/system.nim'.`` + +Nimble cannot find the Nim standard library. This is considered a bug so +please report it. As a workaround you can set the ``NIM_LIB_PREFIX`` environment +variable to the directory where ``lib/system.nim`` (and other standard library +files) are found. + ## Repository information This repository has two main branches: ``master`` and ``stable``. diff --git a/src/nimblepkg/nimscriptsupport.nim b/src/nimblepkg/nimscriptsupport.nim index 5ef3ce3..b3ad381 100644 --- a/src/nimblepkg/nimscriptsupport.nim +++ b/src/nimblepkg/nimscriptsupport.nim @@ -188,7 +188,20 @@ proc setupVM(module: PSym; scriptName: string, flags: Flags): PEvalContext = else: flags[key] = @[value] -proc getNimPrefixDir(): string = splitPath(findExe("nim")).head.parentDir +proc getNimPrefixDir(): string = + let env = getEnv("NIM_LIB_PREFIX") + if env != "": + return env + + result = splitPath(findExe("nim")).head.parentDir + # The above heuristic doesn't work for 'choosenim' proxies. Thankfully in + # that case the `nimble` binary is beside the `nim` binary so things should + # just work. + if not dirExists(result / "lib"): + # By specifying an empty string we instruct the Nim compiler to use + # getAppDir().head as the prefix dir. See compiler/options module for + # the code responsible for this. + result = "" when declared(ModuleGraph): var graph: ModuleGraph