[Dune] Problems with a string return by Dune

Hello everyone,

First of all, sorry for my poor English, I’m pretty new to Dune so I may not fully understand what you reply to this topic and thanks a lot in advance.

So the problem I try to solve is some bash formatting characters are added to the version of the server (here 0.12). As you can see below, this is what i get :

--------------------- Fri May 14 13:30:21 2021 ---------------------
API version mismatch: client v.0.12 and server v.e[m0.12e[0m

and this is the code that produce the line above.

(rule
 (targets VERSION)
 (action (with-stdout-to %{targets}
           (run opam show ./%{dep:./learn-ocaml.opam} -f version --normalise)))
)

I don’t understand how it happens because when I’m trying this command directly in my terminal:

opam show ./learn-ocaml.opam -f version --normalise

It return only 0.12.

Do you have any ideas?

Thanks again for your help.

The issue seems unrelated to dune, but rather due to opam show outputting some ANSI codes that end up in your VERSION file. Try passing --color never:

(rule (with-stdout-to VERSION (run opam show --color=never ...)))

Cheers,
Nicolás

3 Likes

That solution solved my problem, thanks a lot for your help.

Cheers,
Louis.