-
Notifications
You must be signed in to change notification settings - Fork 456
Update tutorial to use autolocking #12859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Leonidas-from-XIV
merged 1 commit into
ocaml:main
from
Leonidas-from-XIV:update-pkg-mgmt-tutorial-autolock
Dec 11, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
doc/tutorials/dune-package-management/dependencies/dune-workspace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| (lang dune 3.21) | ||
| (pkg enabled) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,4 +24,5 @@ setup | |
| dependencies | ||
| pinning | ||
| repos | ||
| locking | ||
| ::: | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # Locking Your Dependencies | ||
|
|
||
| In the default use-case Dune will automatically determine which packages to | ||
| install, by reading the package constrains, determining compatible versions and | ||
| installing the dependencies automatically. | ||
|
|
||
| For many projects this is a good and acceptable behavior as users often want to | ||
| use new versions of their dependencies. However some projects might want to | ||
| keep a fixed set of (transitive) dependencies that is only updated manually. | ||
|
|
||
| ## Create a lock directory 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: | ||
|
|
||
| ``` | ||
| $ dune pkg lock | ||
| Solution for dune.lock: | ||
| - ocaml.5.2.0 | ||
| - ocaml-base-compiler.5.2.0 | ||
| - ocaml-config.3 | ||
| ``` | ||
|
|
||
| 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 and source locations that are necessary | ||
| to build the project's dependencies. | ||
|
|
||
| On the next build, Dune will read the stored solver solution from the | ||
| `dune.lock` directory, download and build the dependencies and then continue on | ||
| building the project as usual. | ||
|
|
||
| The lock directory will not be updated until `dune pkg lock` is rerun. | ||
|
|
||
| :::{note} | ||
| This approach is similar to using `opam switch export --full --freeze` to | ||
| export the configuration of a switch. | ||
| ::: | ||
|
|
||
| Deleting the lock directory will cause Dune to fall back to automatically | ||
| determining dependency versions via the declared package constraints. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| (lang dune 3.17) | ||
| (lang dune 3.21) | ||
|
|
||
| (pkg enabled) | ||
|
|
||
| (lock_dir | ||
| (repositories overlay specific-upstream)) | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.