From 06b9e603bcfe09266c858439c2c530a1c224888f Mon Sep 17 00:00:00 2001 From: Jake Leahy Date: Wed, 24 Jan 2024 08:35:52 +1100 Subject: [PATCH] Show error when trying to run in folder that doesn't exist instead of assertion (#23242) Closes #23240 Fixes regression caused by #23017 --- compiler/main.nim | 3 ++- tests/misc/t23240.nim | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 tests/misc/t23240.nim 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: "" +"""