`touch`ing package sources only works on Windows?

Win

julia> touch(pathof(GMT))
"C:\\Users\\joaqu\\.julia\\dev\\GMT\\src\\GMT.jl"

Linux || Mac

julia> touch(pathof(GMT))
ERROR: IOError: open: permission denied (EACCES)

but like this it does

run(`touch $(pathof(GMT))`)

Works for me on linux. What are is the owner of the file/folder and what is the user running julia?

Thanks for looking.
In two Linux and one Mac I got the same error and this was triggered by a Mac user who reported me the error. It seems that it’s because the package is installed read-only. But then why it works trough run()?

julia> pathof(GMT)
"/home/jluis/.julia/packages/GMT/fORs3/src/GMT.jl"

julia> run(`whoami`)
jluis
Process(`whoami`, ProcessExited(0))

julia> run(`ls -al /home/jluis/.julia/packages/GMT/fORs3/src/GMT.jl`)
-r--r--r--. 1 jluis jluis 9185 Mar 16 08:31 /home/jluis/.julia/packages/GMT/fORs3/src/GMT.jl
Process(`ls -al /home/jluis/.julia/packages/GMT/fORs3/src/GMT.jl`, ProcessExited(0))

Package sources are meant to be immutable unless you dev them. So Windows is the odd one out here. And the unix touch utility seems to get around the readonly restriction on a technicality.

1 Like

OK, Windows and Mauro’s linux :slight_smile:

The “works for me” was on a dev’ed package, as was suggested by your windows example. For just installed packages, I get your error.

1 Like

Yes, my Windows version is dev’d too.

Ah, I had missed that — that’s the difference. The platform difference is a red herring.

Moving away from touching your package source is a very good thing™. There are some recommendations on how to do so here: Creating packages: Best Practices

2 Likes

Do you have an advce of an easy way to force a package recompile (that was the intended purpose of using touch)?

Why do you need the package to recompile? What has changed outside of the package? Edit: oh, I see.

https://github.com/GenericMappingTools/GMT.jl/blob/master/src/GMT.jl#L203-L222

Ideally, you’d use Artifacts to install GMT.

1 Like

Yes, ideally but not possible. I’m reading through conda to try to find a solution but also not easy (BinaryBuider no, GMT on Windows is compiled with VisualStudio and dependencies must be reach).
The current issue is with Homebrew that each time changes the library name and then a recompile is needed to fish the current name.

Set permissions to +w, touch, then restore permission?

You should include a file in the package’s deps folder such as deps/deps.jl and touch that if needed. The deps folder is the one exception to immutability.

But that’s the same (and longer) as doing
run(`touch $(pathof(GMT))`)

This package does not have a deps folder

Perhaps, I’m misunderstanding the situation. My understanding is that you are the developer of the this package, right? You can add one.

  1. Add an empty deps/touch_to_rebuild.jl file to your package.
  2. Add a include( joinpath(dirname(@__DIR__), "deps", "touch_to_rebuild.jl") ) to your package
  3. Make a deps/build.jl that touches touch_to_rebuild.jl

You can tell the user to ] build GMT in order force GMT.jl to find new binaries.

1 Like

Yes, I am the developer and thanks, now I see what you mean.