# \`touch\`ing package sources only works on Windows?

**URL:** <https://discourse.julialang.org/t/touch-ing-package-sources-only-works-on-windows/60903>\
**Category:** General Usage\
**Created:** [May 10, 2021, 5:44pm UTC](https://discourse.julialang.org/t/touch-ing-package-sources-only-works-on-windows/60903 "2021-05-10T17:44:44Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [May 10, 2021, 5:44pm UTC](https://discourse.julialang.org/t/touch-ing-package-sources-only-works-on-windows/60903/1 "2021-05-10T17:44:44Z")

</div>

Win

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

```

Linux || Mac

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

```

but like this it does

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

```

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [May 10, 2021, 7:18pm UTC](https://discourse.julialang.org/t/touch-ing-package-sources-only-works-on-windows/60903/2 "2021-05-10T19:18:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [May 10, 2021, 7:35pm UTC](https://discourse.julialang.org/t/touch-ing-package-sources-only-works-on-windows/60903/3 "2021-05-10T19:35:40Z")

</div>

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
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))

```

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [May 10, 2021, 8:07pm UTC](https://discourse.julialang.org/t/touch-ing-package-sources-only-works-on-windows/60903/4 "2021-05-10T20:07:42Z")

</div>

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](https://redhat-list.redhat.narkive.com/IYYI3q3k/touch-modifies-read-only-files#post3).

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [May 10, 2021, 8:17pm UTC](https://discourse.julialang.org/t/touch-ing-package-sources-only-works-on-windows/60903/5 "2021-05-10T20:17:43Z")

</div>

OK, Windows and Mauro’s linux 🙂

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [May 10, 2021, 8:19pm UTC](https://discourse.julialang.org/t/touch-ing-package-sources-only-works-on-windows/60903/6 "2021-05-10T20:19:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [May 10, 2021, 8:22pm UTC](https://discourse.julialang.org/t/touch-ing-package-sources-only-works-on-windows/60903/7 "2021-05-10T20:22:18Z")

</div>

Yes, my Windows version is dev’d too.

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [May 10, 2021, 8:27pm UTC](https://discourse.julialang.org/t/touch-ing-package-sources-only-works-on-windows/60903/8 "2021-05-10T20:27:48Z")

</div>

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

Moving away from `touch`ing your package source is a very good thing™. There are some recommendations on how to do so here: [Creating packages: Best Practices](https://pkgdocs.julialang.org/dev/creating-packages/#Best-Practices)

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [May 10, 2021, 8:31pm UTC](https://discourse.julialang.org/t/touch-ing-package-sources-only-works-on-windows/60903/9 "2021-05-10T20:31:32Z")

</div>

> [@mbauman](#):
>
> Moving away from `touch` ing your package source is a very good thing

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

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [May 10, 2021, 8:39pm UTC](https://discourse.julialang.org/t/touch-ing-package-sources-only-works-on-windows/60903/10 "2021-05-10T20:39:01Z")

</div>

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](https://github.com/GenericMappingTools/GMT.jl/blob/master/src/GMT.jl#L203-L222)

Ideally, you’d use Artifacts to install GMT.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [May 10, 2021, 8:51pm UTC](https://discourse.julialang.org/t/touch-ing-package-sources-only-works-on-windows/60903/11 "2021-05-10T20:51:54Z")

</div>

> [@mbauman](#):
>
> Ideally, you’d use Artifacts to install GMT.

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.

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [May 10, 2021, 9:10pm UTC](https://discourse.julialang.org/t/touch-ing-package-sources-only-works-on-windows/60903/12 "2021-05-10T21:10:52Z")

</div>

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

---

<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:** [May 10, 2021, 9:40pm UTC](https://discourse.julialang.org/t/touch-ing-package-sources-only-works-on-windows/60903/13 "2021-05-10T21:40:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [May 10, 2021, 9:43pm UTC](https://discourse.julialang.org/t/touch-ing-package-sources-only-works-on-windows/60903/14 "2021-05-10T21:43:33Z")

</div>

> [@mauro3](#):
>
> Set permissions to `+w` , touch, then restore permission?

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

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [May 10, 2021, 9:44pm UTC](https://discourse.julialang.org/t/touch-ing-package-sources-only-works-on-windows/60903/15 "2021-05-10T21:44:29Z")

</div>

> [@mkitti](#):
>
> You should include a file in the package’s `deps` folder

This package does not have a `deps` folder

---

<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:** [May 10, 2021, 9:54pm UTC](https://discourse.julialang.org/t/touch-ing-package-sources-only-works-on-windows/60903/16 "2021-05-10T21:54:05Z")

</div>

> [@joa-quim](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [May 10, 2021, 9:56pm UTC](https://discourse.julialang.org/t/touch-ing-package-sources-only-works-on-windows/60903/17 "2021-05-10T21:56:51Z")

</div>

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