diff --git a/src/dune_pkg/lock_dir.ml b/src/dune_pkg/lock_dir.ml index 5a5774fba09..d41971506e4 100644 --- a/src/dune_pkg/lock_dir.ml +++ b/src/dune_pkg/lock_dir.ml @@ -611,7 +611,9 @@ module Write_disk = struct in match Path.(parent (source lock_dir_path_src)) with | Some parent_dir -> - fun () -> Temp.with_temp_dir ~parent_dir ~prefix:"dune" ~suffix:"lock" ~f:build + fun () -> + Path.mkdir_p parent_dir; + Temp.with_temp_dir ~parent_dir ~prefix:"dune" ~suffix:"lock" ~f:build | None -> User_error.raise [ Pp.textf "Temporary directory can't be created by deriving the lock dir path" ] diff --git a/test/blackbox-tests/test-cases/pkg/lock-directory-regeneration-safety.t/run.t b/test/blackbox-tests/test-cases/pkg/lock-directory-regeneration-safety.t/run.t index d952687e898..3832f01dd48 100644 --- a/test/blackbox-tests/test-cases/pkg/lock-directory-regeneration-safety.t/run.t +++ b/test/blackbox-tests/test-cases/pkg/lock-directory-regeneration-safety.t/run.t @@ -4,10 +4,16 @@ Create a lock directory that didn't originally exist > (lang dune 3.10) > (lock_dir > (repositories mock)) + > (lock_dir + > (path "dev/dune.lock") + > (repositories mock)) > (repository > (name mock) > (source "file://$(pwd)/mock-opam-repository")) > EOF + $ dune pkg lock "dev/dune.lock" + Solution for dev/dune.lock: + (no dependencies to lock) $ dune pkg lock Solution for dune.lock: (no dependencies to lock)