# Enabling and disabling preprocessors with dune

**URL:** <https://discuss.ocaml.org/t/enabling-and-disabling-preprocessors-with-dune/15960>\
**Category:** Learning\
**Tags:** ppx, build, dune\
**Created:** [January 15, 2025, 6:24am UTC](https://discuss.ocaml.org/t/enabling-and-disabling-preprocessors-with-dune/15960 "2025-01-15T06:24:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![adventure](https://avatars.discourse-cdn.com/v4/letter/a/7feea3/32.png) [@adventure](https://discuss.ocaml.org/u/adventure)\
**Post date:** [January 15, 2025, 6:24am UTC](https://discuss.ocaml.org/t/enabling-and-disabling-preprocessors-with-dune/15960/1 "2025-01-15T06:24:46Z")

</div>

Is it possible to enable and disable preprocessors with dune actions, profiles, or dune-workspace? My use case is that I would like to use a preprocessor when I compile with `dune build --profile=debug`, and not compile with the preprocessor when I use `dune build`.

This works, but it causes an error message and I suspect it actually shouldn’t work at all. I also tried expanding environment variables within the preprocess stanza, but that is not allowed. In this example, we only want `ppx_yojson_conv` if we are building with the debug profile.

```auto
(library
 (name my_library)
 (public_name my-library)
 (libraries
  fmt)
 (preprocess
  (pps
   ppx_deriving.std
   ppx_yojson_conv))
 (enabled_if
  (= %{profile} debug)))

(library
 (name my_library)
 (public_name my-library)
 (libraries
  fmt)
 (preprocess
  (pps ppx_deriving.std))
 (enabled_if
  (= %{profile} dev)))

```

---

<div class="post-metadata">

**Author:** ![adventure](https://avatars.discourse-cdn.com/v4/letter/a/7feea3/32.png) [@adventure](https://discuss.ocaml.org/u/adventure)\
**Post date:** [January 15, 2025, 6:59am UTC](https://discuss.ocaml.org/t/enabling-and-disabling-preprocessors-with-dune/15960/2 "2025-01-15T06:59:09Z")

</div>

It appears this is probably my solution, so this thread can probably be deleted:

[https://dune.readthedocs.io/en/stable/instrumentation.html](https://dune.readthedocs.io/en/stable/instrumentation.html)
