When exactly does dune generate .opam-files?

In the documentation on generating .opam files, it says

dune will generate .opam files if the dune-project file

  • sets (generate_opam_files true) , and
  • declares one or more packages as per, Declaring a package.

For a build I’m setting up, I would need dune to generate the .opam file, from the specification in dune-project, in order to afterwards run opam install ., after which the actual package can be built with dune build.

But what actually triggers generating the .opam file? Can dune just generate that file, and then exit?

2 Likes

I believe you have to run dune build, it will generate the .opam file as part of the build.

1 Like

Thanks. Do you usually keep the .opam file in version control then?

Yes, it needs to be committed. It will be regenerated whenever necessary, by running the command. Then check in the changes.

2 Likes