Implement nimLibPrefix config var and add better messages for it.
This commit is contained in:
parent
c271435a84
commit
6354132959
3 changed files with 24 additions and 3 deletions
|
|
@ -358,6 +358,9 @@ You can currently configure the following in this file:
|
||||||
Nimble will also attempt to read the ``http_proxy`` and ``https_proxy``
|
Nimble will also attempt to read the ``http_proxy`` and ``https_proxy``
|
||||||
environment variables.
|
environment variables.
|
||||||
**Default: ""**
|
**Default: ""**
|
||||||
|
* ``nimLibPrefix`` - Specifies the Nim standard library prefix to help Nimble
|
||||||
|
find the Nim standard library.
|
||||||
|
**Default: ""**
|
||||||
|
|
||||||
## Creating Packages
|
## Creating Packages
|
||||||
|
|
||||||
|
|
@ -841,7 +844,8 @@ Make sure that you are running at least version 0.16.0 of Nim (or the latest nig
|
||||||
Nimble cannot find the Nim standard library. This is considered a bug so
|
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
|
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
|
variable to the directory where ``lib/system.nim`` (and other standard library
|
||||||
files) are found.
|
files) are found. Alternatively you can also configure this in Nimble's
|
||||||
|
config file.
|
||||||
|
|
||||||
## Repository information
|
## Repository information
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ type
|
||||||
packageLists*: Table[string, PackageList] ## Names -> packages.json files
|
packageLists*: Table[string, PackageList] ## Names -> packages.json files
|
||||||
cloneUsingHttps*: bool # Whether to replace git:// for https://
|
cloneUsingHttps*: bool # Whether to replace git:// for https://
|
||||||
httpProxy*: Uri # Proxy for package list downloads.
|
httpProxy*: Uri # Proxy for package list downloads.
|
||||||
|
nimLibPrefix*: string # Nim stdlib prefix.
|
||||||
|
|
||||||
PackageList* = object
|
PackageList* = object
|
||||||
name*: string
|
name*: string
|
||||||
|
|
@ -33,6 +34,8 @@ proc initConfig(): Config =
|
||||||
])
|
])
|
||||||
result.packageLists["official"] = defaultPkgList
|
result.packageLists["official"] = defaultPkgList
|
||||||
|
|
||||||
|
result.nimLibPrefix = ""
|
||||||
|
|
||||||
proc initPackageList(): PackageList =
|
proc initPackageList(): PackageList =
|
||||||
result.name = ""
|
result.name = ""
|
||||||
result.urls = @[]
|
result.urls = @[]
|
||||||
|
|
@ -110,6 +113,8 @@ proc parseConfig*(): Config =
|
||||||
else:
|
else:
|
||||||
currentPackageList.path = e.value
|
currentPackageList.path = e.value
|
||||||
else: assert false
|
else: assert false
|
||||||
|
of "nimlibprefix":
|
||||||
|
result.nimLibPrefix = e.value
|
||||||
else:
|
else:
|
||||||
raise newException(NimbleError, "Unable to parse config file:" &
|
raise newException(NimbleError, "Unable to parse config file:" &
|
||||||
" Unknown key: " & e.key)
|
" Unknown key: " & e.key)
|
||||||
|
|
|
||||||
|
|
@ -191,11 +191,19 @@ proc setupVM(module: PSym; scriptName: string, flags: Flags): PEvalContext =
|
||||||
proc isValidLibPath(lib: string): bool =
|
proc isValidLibPath(lib: string): bool =
|
||||||
return fileExists(lib / "system.nim")
|
return fileExists(lib / "system.nim")
|
||||||
|
|
||||||
proc getNimPrefixDir: string =
|
proc getNimPrefixDir(options: Options): string =
|
||||||
let env = getEnv("NIM_LIB_PREFIX")
|
let env = getEnv("NIM_LIB_PREFIX")
|
||||||
if env != "":
|
if env != "":
|
||||||
|
let msg = "Using env var NIM_LIB_PREFIX: " & env
|
||||||
|
display("Warning:", msg, Warning, HighPriority)
|
||||||
return env
|
return env
|
||||||
|
|
||||||
|
if options.config.nimLibPrefix != "":
|
||||||
|
result = options.config.nimLibPrefix
|
||||||
|
let msg = "Using Nim stdlib prefix from Nimble config file: " & result
|
||||||
|
display("Warning:", msg, Warning, HighPriority)
|
||||||
|
return
|
||||||
|
|
||||||
result = splitPath(findExe("nim")).head.parentDir
|
result = splitPath(findExe("nim")).head.parentDir
|
||||||
# The above heuristic doesn't work for 'choosenim' proxies. Thankfully in
|
# The above heuristic doesn't work for 'choosenim' proxies. Thankfully in
|
||||||
# that case the `nimble` binary is beside the `nim` binary so things should
|
# that case the `nimble` binary is beside the `nim` binary so things should
|
||||||
|
|
@ -222,10 +230,14 @@ proc execScript(scriptName: string, flags: Flags, options: Options): PSym =
|
||||||
compiler_options.implicitImports.add("nimblepkg/nimscriptapi")
|
compiler_options.implicitImports.add("nimblepkg/nimscriptapi")
|
||||||
|
|
||||||
# Ensure the compiler can find its standard library #220.
|
# Ensure the compiler can find its standard library #220.
|
||||||
compiler_options.gPrefixDir = getNimPrefixDir()
|
compiler_options.gPrefixDir = getNimPrefixDir(options)
|
||||||
|
display("Setting", "Nim stdlib prefix to " & compiler_options.gPrefixDir,
|
||||||
|
priority=LowPriority)
|
||||||
|
|
||||||
# Verify that lib path points to existing stdlib.
|
# Verify that lib path points to existing stdlib.
|
||||||
compiler_options.setDefaultLibpath()
|
compiler_options.setDefaultLibpath()
|
||||||
|
display("Setting", "Nim stdlib path to " & compiler_options.libpath,
|
||||||
|
priority=LowPriority)
|
||||||
if not isValidLibPath(compiler_options.libpath):
|
if not isValidLibPath(compiler_options.libpath):
|
||||||
let msg = "Nimble cannot find Nim's standard library.\nLast try in:\n - $1" %
|
let msg = "Nimble cannot find Nim's standard library.\nLast try in:\n - $1" %
|
||||||
compiler_options.libpath
|
compiler_options.libpath
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue