Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On Linux, tempname() ignores the ‘parent’ argument if the TMPDIR environment variable is set #35343

Closed
ivan-timokhin opened this issue Apr 2, 2020 · 4 comments

Comments

@ivan-timokhin
Copy link

Because that is the behaviour of the underlying tempnam function. For example, this fails

withenv("TMPDIR" => tempdir()) do
    mktempdir() do d
        t = tempname(d)
        @test dirname(t) == d
    end
end

and, in fact, an existing test in file.jl fails if the testsuite is run with TMPDIR set (which is how I discovered the issue).

I have tried fixing the issue myself (#35342), but the result ended up thread-unsafe, and I don't have any better ideas.

@yuyichao
Copy link
Contributor

yuyichao commented Apr 2, 2020

Why does this function exist anyway... The document for the C function explicitly says don' use it and the glibc implementation isn't fundamentally safer than the windows one anyway....

@ivan-timokhin
Copy link
Author

ivan-timokhin commented Apr 2, 2020

Why does this function exist anyway...

See also #22949 and #9053.

@StefanKarpinski
Copy link
Member

Agree, we should probably just have our own implementation of this that doesn't use tempnam.

@laborg
Copy link
Contributor

laborg commented Feb 7, 2022

This has been fixed on master by #38879

#Julia Version 1.8.0-DEV.1440
#Commit e3b681c687 (2022-02-02 01:39 UTC)
julia> withenv("TMPDIR" => tempdir()) do
           mktempdir() do d
               t = tempname(d)
               @test dirname(t) == d
           end
       end
Test Passed

@laborg laborg closed this as completed Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants