dune icon indicating copy to clipboard operation
dune copied to clipboard

pkg: dune watch mode with autolocking

Open maiste opened this issue 10 months ago • 0 comments

I'm opening this PR to discuss the best way to introduce the auto locking inside the watch-mode. Being able to auto-lock the dependencies will developing would be really useful. The solution I have in mind would remove some of the problem that were raised.

The solution would consist in 3 stages:

  1. First, we would need to track the dune.lock directory as a target of the dune pkg lock command and as an input for the dune build command. We could use the "promote" mechanism to make it changes the file in the source directory. This is what is currently used by dune fmt and we could imagine dune pkg lock following the same pattern.
  2. The next stage would be that in watch mode, when you change the dependencies in a dune-project or *.opam file, it would update the generated dune.lock entry only for the new package. We would provide the exact version we already have for the other packages. If it fails to build, we would ask the user to manually run dune pkg lock because it would mean a "strong" upgrade.
  3. To prevent the user from going into this auto lock mode, @Alizter suggested guarding it with an ``--auto-lock` flag. IMO, this is a good idea. It would allow users to quickly add their dependencies when beginning a project and later remove the flag when they don't expect to introduce dependencies.

Solving being the costly part in the process, doing it only with the flag would prevent it from happening when users don't expect it.

I have started to dig a bit in the code on how to do this. However, before going further, I would like to get your feedback on this @rgrinberg. WDTY of this solution?

maiste avatar Apr 07 '25 16:04 maiste