nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.54k stars 1.47k forks source link

Building Nim in a directory whose name has to be escaped fails #22702

Open konsumlamm opened 1 year ago

konsumlamm commented 1 year ago

Description

My Nim fork is in a directory called $Contributions. Running nim c koch.nim && ./koch temp results in an error:

~/.nimble/bin/nim c -d:debug --debugger:native -d:nimBetterRun  -d:leanCompiler ~/Projects/Nim/$Contributions/Nim/compiler/nim
oserrors.nim(92)         raiseOSError
Error: unhandled exception: No such file or directory
Additional info: ~/Projects/Nim//Nim/compiler [OSError]
FAILURE

This is because koch uses execShellCmd, which doesn't escape the path name.

Similarly, having a space in the path (which is probably more common) also results in an error.

Nim Version

Nim Compiler Version 2.1.1 [Linux: amd64] Compiled at 2023-09-14 Copyright (c) 2006-2023 by Andreas Rumpf

git hash: ac1804aba665b34a01cb014183f8fff0ba6db738 active boot switches: -d:release

Varriount commented 1 year ago

@Yardanico Might be worth having Nim's CI/CD mechanism run in a path containing special/unusual characters, to catch cases like this.

ringabout commented 1 year ago

I don't think Nim generally escape paths for this case,

wind@DESKTOP-M4S17KE:~/$Contributions/Nim$ nim c --nimcache:xcache koch.nim
command line(1, 2) Error: invalid path: /home/wind/$Contributions/Nim/xcache

It failed too.