Skip to content
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

pkg: dune pkg lock "dev/dune.lock" fails, because dune.lock is a sub-directory. #10866

Closed
moyodiallo opened this issue Aug 30, 2024 · 3 comments · Fixed by #10876
Closed

pkg: dune pkg lock "dev/dune.lock" fails, because dune.lock is a sub-directory. #10866

moyodiallo opened this issue Aug 30, 2024 · 3 comments · Fixed by #10876
Assignees

Comments

@moyodiallo
Copy link
Collaborator

Expected Behavior

Do not crash

Actual Behavior

+|  Internal error, please report upstream including the contents of _build/log.
+|  Description:
+|    ("[Temp.create_temp_dir] called in a nonexistent directory",
+|    { dir = In_source_tree "dev/dune_3b32f9_lock" })
+|  Raised at Stdune__Result.ok_exn in file "otherlibs/stdune/src/result.ml",
+|    line 26, characters 15-22
+|  Called from Dune_pkg__Lock_dir.Write_disk.prepare.build in file
+|    "src/dune_pkg/lock_dir.ml", line 584, characters 26-53
+|  Called from Stdlib__List.iter in file "list.ml", line 110, characters 12-15
+|  Called from Fiber__Core.O.(>>|).(fun) in file "vendor/fiber/src/core.ml",
+|    line 253, characters 36-41
+|  Called from Fiber__Scheduler.exec in file "vendor/fiber/src/scheduler.ml",
+|    line 76, characters 8-11
+|  
+|  I must not crash.  Uncertainty is the mind-killer. Exceptions are the
+|  little-death that brings total obliteration.  I will fully express my cases. 
+|  Execution will pass over me and through me.  And when it has gone past, I
+|  will unwind the stack along its path.  Where the cases are handled there will
+|  be nothing.  Only I will remain.
+|  [1]

Reproduction

What the reproduction does is:

  1. Apply the patch
  2. And run the test
git apply <<'EOF'
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 d952687e8..093ef0f39 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,14 @@ 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"
   $ dune pkg lock
   Solution for dune.lock:
   (no dependencies to lock)
EOF
dune build @test/blackbox-tests/test-cases/pkg/lock-directory-regeneration-safety

Additional information

This is coming from the #10852, the parent directory was not created before creating the temporary directory.

@moyodiallo moyodiallo changed the title pkg: dune pkg lock "dev/dune.lock" fails, because "dune.lock" is a sub-directory. pkg: dune pkg lock "dev/dune.lock" fails, because dune.lock is a sub-directory. Aug 30, 2024
@maiste
Copy link
Collaborator

maiste commented Sep 2, 2024

My first bet would be that it's related to the fact that with the atomic locking, we derived the path from the provided path.

@moyodiallo
Copy link
Collaborator Author

The issue is coming from:

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

When parent_dir does not exist, creating the tmp directory fails.

@rgrinberg
Copy link
Member

Do you want to send a test + a fix? I think you just need an mkdir on the parent_dir

@maiste maiste self-assigned this Sep 3, 2024
maiste added a commit to maiste/dune that referenced this issue Sep 3, 2024
maiste added a commit to maiste/dune that referenced this issue Sep 3, 2024
Signed-off-by: Etienne Marais <dev@maiste.fr>
maiste added a commit to maiste/dune that referenced this issue Sep 3, 2024
Signed-off-by: Etienne Marais <dev@maiste.fr>
maiste added a commit to maiste/dune that referenced this issue Sep 3, 2024
Signed-off-by: Etienne Marais <dev@maiste.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants