Skip to content

Commit

Permalink
fixing segfault when TMPDIR is non-existing
Browse files Browse the repository at this point in the history
  • Loading branch information
miki725 committed Nov 3, 2023
1 parent 77cd56c commit 8c5799f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/util.nim
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ proc setupManagedTemp*() =
if customTmpDirOpt.isSome() and not existsEnv("TMPDIR"):
putenv("TMPDIR", customTmpDirOpt.get())

# temp folder needs to exist in order to successfully create
# tmp files otherwise nim's createTempFile throws segfault
# when TMPDIR does not exist
if existsEnv("TMPDIR"):
discard existsOrCreateDir(getEnv("TMPDIR"))

if chalkConfig.getChalkDebug():
info("Debug is on; temp files / dirs will be moved, not deleted.")
setManagedTmpCopyLocation(resolvePath("chalk-tmp"))
Expand Down

0 comments on commit 8c5799f

Please sign in to comment.