Dune run external command without targets

Hi all,

For an opam package of mine, that I have pinned, after building the sources I need to run an external program. I was think about using the (action (run ...)) stanza, but the problem is that my external program does not produce any file, so I would have an empty targets list.

I was thinking about something as follows:

  (targets )
  (deps plugin_why3gospel.cmxs)
  (action (run why3 config --install-plugin %{deps})))

but of course this will fail due the empty targets list.

Is there any way to say in my dune file that I need to run why3 config ... ?

In dune 2, you can define a rule with an empty target list, attaching it to an “alias” instead:

 (alias foo)
 (action (run ...))))

You can then trigger the alias by doing dune build @foo.

Thank you very much @nojb , that seems to help :slight_smile:

However, via an opam installation, I get the Read-only file system error. I believe this is due to the sandboxing of opam, right?

Any ideas on how to solve this?

Sorry, I am not very familiar with opam, but if your “action” is trying to escape the sandbox it may not be possible to do it as part of the opam build/installation step.