Skip to content

Conversation

@Leonidas-from-XIV
Copy link
Collaborator

Updates to the tutorial to use autolocking (plus explain how to manually lock).

Closes #12796

@Leonidas-from-XIV
Copy link
Collaborator Author

Unfortunately I had to remove a lot of output where the solution was displayed, because with autolocking the solution is not displayed anymore. I've opened #12865 to discuss how to improve the user experience in that case, giving a users a way to figure out which packages + versions were selected by the solver.

@Leonidas-from-XIV Leonidas-from-XIV force-pushed the update-pkg-mgmt-tutorial-autolock branch from c435b75 to eb5bcf5 Compare December 5, 2025 10:18
@Leonidas-from-XIV Leonidas-from-XIV marked this pull request as ready for review December 5, 2025 10:18
Comment on lines 5 to 6
packages are published in the opam-repository occasionally, Dune might pick
different solutions over time.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this isn't a very robust account of the dynamics at play. Whether or not new packages are published, different builds can end up with different dependencies based on a number of factors: the system run on, the which repos are pinned, whether or not the user has had connectivity, whether packages are marked unavailable, etc. I think it's better to just describe the core need that motivates locking. And you do that in the next paragraph. So maybe this sentence can be removed?

@Leonidas-from-XIV Leonidas-from-XIV force-pushed the update-pkg-mgmt-tutorial-autolock branch 2 times, most recently from aad05d3 to 15a0e31 Compare December 8, 2025 15:29
@Leonidas-from-XIV Leonidas-from-XIV changed the title Update documentation to use autolocking Update tutorial to use autolocking Dec 8, 2025
Copy link
Collaborator

@Sudha247 Sudha247 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to have this updated!

Some remarks below. I also found mentions of dune pkg lock in howto/use-opam-alongside-dune-package-management.rst and howto/homebrew-package.rst which we might want to check.

@shonfeder
Copy link
Member

Is this ready for another review? Or is it still being worked on?

@Leonidas-from-XIV
Copy link
Collaborator Author

Yes, I welcome some reviews so maybe we can get it merged in time for 3.21.

@Leonidas-from-XIV Leonidas-from-XIV force-pushed the update-pkg-mgmt-tutorial-autolock branch from 598ff93 to eebe860 Compare December 10, 2025 14:02
longer than usual, as the dependencies need to be built first. Subsequent
builds where all dependencies have been built before will be just as fast as
before.
Since this is the first time we have run the build system after enabling package
Copy link
Collaborator

@Sudha247 Sudha247 Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems this is getting folded in the collapsible dune-workspace. I'm not sure that is intended?

Copy link
Collaborator

@Sudha247 Sudha247 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've gone through the tutorial once to validate we get the expected results, and we do. I think this is good to go.

Copy link
Member

@shonfeder shonfeder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few more suggestions, but they don't need to blocking.

Comment on lines +36 to +38
In this file we let Dune know to enable package management in the current
workspace. This way Dune will know that it is expected to install the
dependencies automatically.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(re)reading this, the anthropomorphism of Dune stands out to me. I think we can be more direct, and know attributing any "knowing" ;)

Suggested change
In this file we let Dune know to enable package management in the current
workspace. This way Dune will know that it is expected to install the
dependencies automatically.
In this file we direct Dune to enable package management in the current
workspace. This configures Dune to manage the declared dependencies automatically.


which will download and install the new dependencies and build our project as
before.
This will recongnize that the project depends on new packages. Thus it will
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does 'this' refer to here?

Comment on lines 12 to 13
(lock_dir
(repositories overlay1 upstream1))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, that is awkward :( seems to be leaking implementation details, but that can be addressed in some followup.

Comment on lines +13 to +16
Dune resolves dependencies by creating an internal lock directory
automatically. However, if an manually created lock directory exists in the
source, Dune will use that one instead. The default name of said lock directory
is `dune.lock`, and it can be created manually:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, it is confusing to talk about these internal implementation details in docs like this. Users shouldn't care what dune with its private dirs, they just need to know the user-facing behavior and properties. Referring to a "lock" directory that doesn't actually server to lock anything is going to get people confused, I predict.

Suggested change
Dune resolves dependencies by creating an internal lock directory
automatically. However, if an manually created lock directory exists in the
source, Dune will use that one instead. The default name of said lock directory
is `dune.lock`, and it can be created manually:
If a lock directory exists in the source, Dune will use that to fix the exact version and source of dependencies. The default name of said lock directory
is `dune.lock`. Lock directories are created with:

## Create a lock directory manually

Dune resolves dependencies by creating an internal lock directory
automatically. However, if an manually created lock directory exists in the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At minimum:

Suggested change
automatically. However, if an manually created lock directory exists in the
automatically. However, if a manually created lock directory exists in the


Whenever Dune encounters a `dune.lock` folder, it will use the set of
dependencies defined in the lock. It contains all the metadata about package
names and versions, their dependencies & source locations that are necesary to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
names and versions, their dependencies & source locations that are necesary to
names and versions, their dependencies and source locations that are necessary to

Whenever Dune encounters a `dune.lock` folder, it will use the set of
dependencies defined in the lock. It contains all the metadata about package
names and versions, their dependencies & source locations that are necesary to
build the projects dependencies.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
build the projects dependencies.
build the project's dependencies.

Comment on lines +35 to +36
The lock directory will not be updated until a new lock directory is created,
by rerunning `dune pkg lock`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The lock directory will not be updated until a new lock directory is created,
by rerunning `dune pkg lock`.
The lock directory will not be updated until `dune pkg lock` is rerun.

export the configuration of a switch.
:::

Deleting the lock directory switches Dune back into automatically determining
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid possible confusion with switch in the note above:

Suggested change
Deleting the lock directory switches Dune back into automatically determining
Deleting the lock directory will cause Dune to fall back to automatically determining

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation improvements package management

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update documentation for autolocking

3 participants