Updated dune starter kit

The goal of this 3rd-party repository is to provide a minimal and idiomatic template for setting up an OCaml project. It was just updated to use dune instead of jbuilder.

For those migrating, the changes are minimal and detailed migration help is given by the official docs.


This seems somewhat incovenient to use.
Couldn’t we get some sort dune init command?

Something like:

$ dune init --project package_name
# creates: dune-project, package_name.opam, ... (perhaps a Makefile?)
# in the cwd
$ mkdir my_lib
$ cd my_lib
$ dune init --library my_lib
# create a dune file with the relevant template

Ping @rgrinberg, @jeremiedimino. :slight_smile:


I agree that such a command should be added. Previously, I was against such a command because I thought it could have been implemented just as easily externally. While that may be correct, such an approach will not result in a smooth user experience. So I would certainly be in favor of adding such a command. Anyone who would like to drive the effort on this should get in touch with the dune maintainers.


I have a dead simple, feature poor tool in this direction which I’ve used for my own toy purposes: https://github.com/shonfeder/nomad

Its in’t updated to use the dune rebranding or to be compliant with the new release.

I’m glad to hear that the views about integrating this functionality directly into dune have changed! I’d be happy to help with that effort.


FWIW, I had the vague idea that it’s an IDE’s job to manage the project’s build system. I think we’d need dune files to be simple enough to be manageable by a program (IDE) while remaining editable manually. The IDE could bail if it encounters unknown directives or if certain assumptions on the project structure are violated.

It would be nice to just click to add a component, choose its type (public library, private library, collection of executables, etc.), specify dependencies and give it a name. I don’t have much experience using such IDE features let alone designing them but it seems like they would or should exist elsewhere.

1 Like

Some of us prefer doing this stuff by hand, or using very lightweight tools. (There are many things I want automated in my dev environment, but this isn’t one of them.)

I was merely pointing out that dune init is an IDE feature.

1 Like

Or dune init can be a cli feature that can be invoked by an IDE (and therefore not specific to any editor – unless you’re refering to a different meaning of IDE).

The experience of using Java + Gradle with Intellij IDEA is sort of like this and I agree it’s helpful.

But that said, your starter kit looks neat as a reference implementation for starting out, thanks for that!

1 Like

I agree that ideally this would not be a feature for dune to provide. Unfortunately, in practice the situation makes it very hard to punt this functionality to an IDE. First of all, there’s no single IDE preferred by OCaml users and no single protocol that would support this feature (like LSP). So this means that every text editor would have to implement this functionality from scratch. Given the probability of duplicate effort, and the fact that most text editors use programming languages far inferior to OCaml, doing this in dune is the lesser of all evils.

In the future, it would be nicer for dune to have a more complete way of exposing the internals of the project structure for real IDE’s to operate on.