# Dune run external command without targets

**URL:** <https://discuss.ocaml.org/t/dune-run-external-command-without-targets/5058>\
**Category:** Ecosystem\
**Tags:** dune\
**Created:** [January 21, 2020, 3:26pm UTC](https://discuss.ocaml.org/t/dune-run-external-command-without-targets/5058 "2020-01-21T15:26:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mariopereira](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/mariopereira/32/2391_2.png) [@mariopereira](https://discuss.ocaml.org/u/mariopereira)\
**Post date:** [January 21, 2020, 3:26pm UTC](https://discuss.ocaml.org/t/dune-run-external-command-without-targets/5058/1 "2020-01-21T15:26:07Z")

</div>

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:

```auto
(rule
  (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 ...` ?

---

<div class="post-metadata">

**Author:** ![nojb](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/nojb/32/519_2.png) [@nojb](https://discuss.ocaml.org/u/nojb)\
**Post date:** [January 21, 2020, 3:49pm UTC](https://discuss.ocaml.org/t/dune-run-external-command-without-targets/5058/2 "2020-01-21T15:49:54Z")

</div>

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

```auto
(rule
 (alias foo)
 (action (run ...))))

```

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

---

<div class="post-metadata">

**Author:** ![mariopereira](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/mariopereira/32/2391_2.png) [@mariopereira](https://discuss.ocaml.org/u/mariopereira)\
**Post date:** [January 21, 2020, 4:34pm UTC](https://discuss.ocaml.org/t/dune-run-external-command-without-targets/5058/3 "2020-01-21T16:34:19Z")

</div>

Thank you very much @nojb , that seems to help 🙂

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?

---

<div class="post-metadata">

**Author:** ![nojb](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/nojb/32/519_2.png) [@nojb](https://discuss.ocaml.org/u/nojb)\
**Post date:** [January 21, 2020, 4:46pm UTC](https://discuss.ocaml.org/t/dune-run-external-command-without-targets/5058/4 "2020-01-21T16:46:09Z")

</div>

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.
