# Mktempdir bug

**URL:** <https://discourse.julialang.org/t/mktempdir-bug/103022>\
**Category:** General Usage\
**Created:** [August 21, 2023, 10:26am UTC](https://discourse.julialang.org/t/mktempdir-bug/103022 "2023-08-21T10:26:31Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mikhail\_Kagalenko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikhail_kagalenko/32/13257_2.png) [@Mikhail\_Kagalenko](https://discourse.julialang.org/u/Mikhail_Kagalenko)\
**Post date:** [August 21, 2023, 10:26am UTC](https://discourse.julialang.org/t/mktempdir-bug/103022/1 "2023-08-21T10:26:31Z")

</div>

Julia has an [issue](https://github.com/JuliaLang/julia/issues/47730) caused by `mktempdir()` that prevents precompiling of multiple packages on affected systems. This bug is three or more years old, yet is manifested sporadically, which is probably why it has not been fixed yet. I am looking for some workaround, perhaps, overloading the `mktempdir()` function, because at present it makes the Julia language unusable on affected computers.

---

<div class="post-metadata">

**Author:** ![Mikhail\_Kagalenko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikhail_kagalenko/32/13257_2.png) [@Mikhail\_Kagalenko](https://discourse.julialang.org/u/Mikhail_Kagalenko)\
**Post date:** [August 25, 2023, 11:34am UTC](https://discourse.julialang.org/t/mktempdir-bug/103022/2 "2023-08-25T11:34:10Z")

</div>

This issue is also present in the latest release 1.9.3, same error from libuv.jl:100

---

<div class="post-metadata">

**Author:** ![Mikhail\_Kagalenko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikhail_kagalenko/32/13257_2.png) [@Mikhail\_Kagalenko](https://discourse.julialang.org/u/Mikhail_Kagalenko)\
**Post date:** [November 25, 2023, 5:12pm UTC](https://discourse.julialang.org/t/mktempdir-bug/103022/3 "2023-11-25T17:12:21Z")

</div>

Julia is practically unusable on Windows 7 due to this, because it makes it impossible to install many popular packages, such as Images.jl . The issue is still present in 1.9.4 release.

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [November 25, 2023, 5:48pm UTC](https://discourse.julialang.org/t/mktempdir-bug/103022/4 "2023-11-25T17:48:08Z")

</div>

Did you set the environment variable `TMPDIR` ?

```julia
julia> ENV["TMPDIR"] = joinpath(pwd(), "temporary")
"/home/mkitti/temporary"

julia> mkdir(ENV["TMPDIR"])
"temporary"

julia> mktempdir()
"/home/mkitti/temporary/jl_1AnfFW"

```

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [November 25, 2023, 5:58pm UTC](https://discourse.julialang.org/t/mktempdir-bug/103022/5 "2023-11-25T17:58:33Z")

</div>

Also see [GetTempPathW function (fileapi.h) - Win32 apps | Microsoft Learn](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppathw)

So perhaps change the environment variable `TMP` or `TEMP`.

Also libuv xref:  
[https://docs.libuv.org/en/v1.x/misc.html#c.uv\_os\_tmpdir](https://docs.libuv.org/en/v1.x/misc.html#c.uv_os_tmpdir)

---

<div class="post-metadata">

**Author:** ![Mikhail\_Kagalenko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikhail_kagalenko/32/13257_2.png) [@Mikhail\_Kagalenko](https://discourse.julialang.org/u/Mikhail_Kagalenko)\
**Post date:** [December 2, 2023, 3:34pm UTC](https://discourse.julialang.org/t/mktempdir-bug/103022/6 "2023-12-02T15:34:08Z")

</div>

That does nothing whatsoever for the precompile error.

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [December 3, 2023, 2:19am UTC](https://discourse.julialang.org/t/mktempdir-bug/103022/7 "2023-12-03T02:19:54Z")

</div>

Did it change the location of the temporary directory?

---

<div class="post-metadata">

**Author:** ![Mikhail\_Kagalenko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikhail_kagalenko/32/13257_2.png) [@Mikhail\_Kagalenko](https://discourse.julialang.org/u/Mikhail_Kagalenko)\
**Post date:** [December 7, 2023, 9:13am UTC](https://discourse.julialang.org/t/mktempdir-bug/103022/8 "2023-12-07T09:13:46Z")

</div>

No

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [December 7, 2023, 10:40am UTC](https://discourse.julialang.org/t/mktempdir-bug/103022/9 "2023-12-07T10:40:10Z")

</div>

Try these directions to see if changing the temporary directory location helps:

[https://answers.microsoft.com/en-us/windows/forum/all/change-location-of-temp-files-folder-to-another/19f13330-dde1-404c-aa27-a76c0b450818](https://answers.microsoft.com/en-us/windows/forum/all/change-location-of-temp-files-folder-to-another/19f13330-dde1-404c-aa27-a76c0b450818)

---

<div class="post-metadata">

**Author:** ![Mikhail\_Kagalenko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikhail_kagalenko/32/13257_2.png) [@Mikhail\_Kagalenko](https://discourse.julialang.org/u/Mikhail_Kagalenko)\
**Post date:** [December 7, 2023, 12:03pm UTC](https://discourse.julialang.org/t/mktempdir-bug/103022/10 "2023-12-07T12:03:00Z")

</div>

On what grounds do you expect that changing precompilation directory will make any difference?

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [December 7, 2023, 12:30pm UTC](https://discourse.julialang.org/t/mktempdir-bug/103022/11 "2023-12-07T12:30:17Z")

</div>

The reported error is a file permission issue. Perhaps if you relocate the temporary directory to a directory where you more clearly have file permissions, there might not be a problem deleting the temporary files.

I was inspecting the source code, and there have been changes to this part of the Julia code that may resolve the issue.  
In particular, it seems that this function should only warn if there an issue deleting these files. There have also been changes in this area with regard to precompilation.

> <https://github.com/JuliaLang/julia/blob/39ccdb27990d0095d44715394bf2cb18f6b14dd3/base/file.jl#L552>

Could you try the nightly builds and report the stacktrace if the error still occurs?

> **[Julia Downloads (nightly binaries)](https://julialang.org/downloads/nightlies/)**
>
> The official website for the Julia Language. Julia is a language that is fast, dynamic, easy to use, and open source. Click here to learn more.
