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

realpath() and macOS Catalina #33545

Closed
cormullion opened this issue Oct 13, 2019 · 19 comments
Closed

realpath() and macOS Catalina #33545

cormullion opened this issue Oct 13, 2019 · 19 comments
Labels
system:mac Affects only macOS

Comments

@cormullion
Copy link
Contributor

cormullion commented Oct 13, 2019

On last year's macOS (Mojave), I can do this:

cd(homedir() * "/.julia/registries/General")
map(realpath, readdir())

and get a 31-element Array{String,1}:.

On this year's macOS (Catalina), it goes wrong:

ERROR: SystemError: realpath: No such file or directory
Stacktrace:
 [1] #systemerror#44(::Nothing, ::typeof(systemerror), ::Symbol, ::Bool) at ./error.jl:134
 [2] systemerror at ./error.jl:134 [inlined]
 [3] realpath(::String) at ./path.jl:380
 [4] iterate at ./generator.jl:47 [inlined]
 [5] collect_to! at ./array.jl:651 [inlined]
 [6] collect_to_with_first!(::Array{String,1}, ::String, ::Base.Generator{Array{String,1},typeof(realpath)}, ::Int64) at ./array.jl:630
 [7] _collect(::Array{String,1}, ::Base.Generator{Array{String,1},typeof(realpath)}, ::Base.EltypeUnknown, ::Base.HasShape{1}) at ./array.jl:624
 [8] collect_similar(::Array{String,1}, ::Base.Generator{Array{String,1},typeof(realpath)}) at ./array.jl:548
 [9] map(::Function, ::Array{String,1}) at ./abstractarray.jl:2073
 [10] top-level scope at none:0

I'm curious if anyone else can reproduce this, or is it just a problem for me... :)

Edit: Julia 1.2. It’s fine on version 1.1.

@Nosferican
Copy link
Contributor

Works fine for me.

@ViralBShah ViralBShah added the system:mac Affects only macOS label Oct 13, 2019
@dkarrasch
Copy link
Member

Can reproduce on Julia v1.2, but works fine on v1.3 and a 5-day-old nightly.

@cormullion
Copy link
Contributor Author

i ran the Julia 1.2 tests - the ones with realpath all failed with similar errors. Eg

Error in testset file:
Error During Test at /Applications/Julia-1.2.app/Contents/Resources/julia/share/julia/test/file.jl:1051
  Test threw exception
  Expression: basename(realpath(uppercase(path))) == path
  SystemError: realpath: No such file or directory
  Stacktrace:
   [1] #systemerror#44(::Nothing, ::typeof(systemerror), ::Symbol, ::Bool) at ./error.jl:134
``

@cormullion
Copy link
Contributor Author

I think this is caused by the new security features introduced in Catatonia. If you open System Preferences>Privacy>Full Disk Access, and add the Julia application to the list of ‘approved’ apps, these start to work again. Might be wrong... 😀

@mkschleg
Copy link

Adding Julia app and the bin to the approved apps list seems to work, but it seems like this issue also persists when re-running this function multiple times in a row really quickly.

julia> realpath(".")
"/Users/Matt/Documents/Developer_Projects/JuliaDev/Reproduce.jl"

julia> realpath(".")
"/Users/Matt/Documents/Developer_Projects/JuliaDev/Reproduce.jl"

julia> realpath(".")
"/Users/Matt/Documents/Developer_Projects/JuliaDev/Reproduce.jl"

julia> realpath(".")
ERROR: SystemError: realpath: No such file or directory
Stacktrace:
 [1] #systemerror#44(::Nothing, ::typeof(systemerror), ::Symbol, ::Bool) at ./error.jl:134
 [2] systemerror at ./error.jl:134 [inlined]
 [3] realpath(::String) at ./path.jl:380
 [4] top-level scope at REPL[6]:1

And it still seems really unreliable. Works maybe 1/4 of the time for me, and usually after letting the function "cool down" for a few seconds which is not ideal.

@StefanKarpinski
Copy link
Member

I don't know whether to laugh or cry. WTF, Apple?

@mkschleg
Copy link

mkschleg commented Oct 18, 2019

Building from source also doesn't seem to fix it.

I don't know whether to laugh or cry. WTF, Apple?

More like pull my hair out...

@mkschleg
Copy link

mkschleg commented Oct 18, 2019

Also this is all with Julia 1.1.1, but I've had similar issues with 1.2.

@vtjnash
Copy link
Member

vtjnash commented Oct 18, 2019

Maybe this explains why I've heard it being called macOS 10.15 Vista https://twitter.com/tylerhall/status/1181324733893287938

@mkschleg
Copy link

Definitely has to do with the new privacy stuff. I'm just happy I have a backup on Mojave and a Linux server to actually run experiments...

@mkschleg
Copy link

As with @dkarrasch the 1.3 release candidate works for me. I'm not sure what the difference between 1.1, 1.2, and 1.3. But I had not installed 1.3 before in Mojave, but that would be really odd if it mattered.

@jwscook
Copy link

jwscook commented Nov 7, 2019

@cormullion's fix works for me. Thanks!

I think this is caused by the new security features introduced in Catatonia. If you open System Preferences>Privacy>Full Disk Access, and add the Julia application to the list of ‘approved’ apps, these start to work again. Might be wrong... 😀

@vtjnash
Copy link
Member

vtjnash commented Nov 7, 2019

This seems to mean that lstat must have failed on some prefix in the path (https://opensource.apple.com/source/Libc/Libc-498/stdlib/FreeBSD/realpath.c.auto.html)

@DilumAluthge
Copy link
Member

Maybe backporting #33116 would fix this on Julia 1.2?

@mkschleg
Copy link

This function seems to fix the issue in 1.1.1 just from implementing in the repl. So a backport should fix the issue.

@vtjnash
Copy link
Member

vtjnash commented Nov 15, 2019

That's all rather nonsensical then—that commit is mostly NFCI and just removes some platform specific branches by utilizing the ones already in libuv.

@ghost
Copy link

ghost commented Nov 16, 2019

@cormullion's fix works for me. Thanks!

I think this is caused by the new security features introduced in Catatonia. If you open System Preferences>Privacy>Full Disk Access, and add the Julia application to the list of ‘approved’ apps, these start to work again. Might be wrong... 😀

Didn't help me.

@vtjnash
Copy link
Member

vtjnash commented Dec 23, 2019

Turns out that "realpath" on macOS gets sometimes renamed to "realpath$DARWIN_EXTSN" (aka _DARWIN_BETTER_REALPATH), so switching to libuv would actually introduce functional changes in behavior.

julia> ccall("realpath\$DARWIN_EXTSN", Cstring, (Cstring, Cstring), "./..", C_NULL)
Cstring(0x00007fedba8c0c00)

julia> unsafe_string(ans)
"/Users/jameson"

$ nm usr/lib/libuv.a | grep realpath
                 U _realpath$DARWIN_EXTSN

Though those changes aren't entirely new (https://github.com/unofficial-opensource-apple/Libc/blob/master/stdlib/FreeBSD/realpath.c from 6 years ago was 10.9).

@vtjnash
Copy link
Member

vtjnash commented Nov 2, 2020

Fixed by #33116

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
system:mac Affects only macOS
Projects
None yet
Development

No branches or pull requests

10 participants