diff --git a/compiler/main.nim b/compiler/main.nim index 742530c071..4d472da6f9 100644 --- a/compiler/main.nim +++ b/compiler/main.nim @@ -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 diff --git a/tests/misc/t23240.nim b/tests/misc/t23240.nim new file mode 100644 index 0000000000..d5edcefe82 --- /dev/null +++ b/tests/misc/t23240.nim @@ -0,0 +1,6 @@ +discard """ + cmd: "nim c foo/bar.nim" + action: "reject" + errormsg: "cannot open 'foo/'" + file: "" +"""