touch fails if file is not owned by user, and even if user has permissions on file.
tan@tanlt ~ $ touch /tmp/abc
tan@tanlt ~ $ sudo chown root:root /tmp/abc
tan@tanlt ~ $ sudo chmod 777 /tmp/abc
tan@tanlt ~ $ ls -la /tmp/abc
-rwxrwxrwx 1 root root 0 Aug 22 08:42 /tmp/abc
tan@tanlt ~ $ touch /tmp/abc
tan@tanlt ~ $ julia10
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.0.0 (2018-08-08)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> touch("/tmp/abc")
ERROR: IOError: futime: operation not permitted (EPERM)
Stacktrace:
[1] uv_error at ./libuv.jl:85 [inlined]
[2] futime at ./filesystem.jl:143 [inlined]
[3] touch(::String) at ./file.jl:407
[4] top-level scope at none:0
Goes through if file ownership is changed:
shell> sudo chown tan:tan /tmp/abc
julia> touch("/tmp/abc")
"/tmp/abc"
~Maybe we should use UTIME_NOW here~
It seems like using uv_fs_futime here may not be appropriate (at least on unix). I have made a PR (#28819) using futimes instead which seems to do the job.
I don't know whether Windows is affected too, but as per https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-setfiletime calling the libuv API should be okay.
I think this is triggering a bug within Pkg, see: https://discourse.julialang.org/t/shared-julia-environment/14206/
Fixed by #28819. Closing.
Most helpful comment
I think this is triggering a bug within
Pkg, see: https://discourse.julialang.org/t/shared-julia-environment/14206/