Show error when trying to run in folder that doesn't exist instead of assertion (#23242)

Closes #23240

Fixes regression caused by #23017
This commit is contained in:
Jake Leahy
2024-01-24 08:35:52 +11:00
committed by GitHub
parent ee984f8836
commit 06b9e603bc
2 changed files with 8 additions and 1 deletions

View File

@@ -326,7 +326,8 @@ proc mainCommand*(graph: ModuleGraph) =
# so by default should not end up in $PWD nor in $projectPath.
var ret = if optUseNimcache in conf.globalOptions: getNimcacheDir(conf)
else: conf.projectPath
doAssert ret.string.isAbsolute # `AbsoluteDir` is not a real guarantee
if not ret.string.isAbsolute: # `AbsoluteDir` is not a real guarantee
rawMessage(conf, errCannotOpenFile, ret.string & "/")
if conf.cmd in cmdDocLike + {cmdRst2html, cmdRst2tex, cmdMd2html, cmdMd2tex}:
ret = ret / htmldocsDir
conf.outDir = ret

6
tests/misc/t23240.nim Normal file
View File

@@ -0,0 +1,6 @@
discard """
cmd: "nim c foo/bar.nim"
action: "reject"
errormsg: "cannot open 'foo/'"
file: ""
"""