diff --git a/src/dune_pkg/rev_store.ml b/src/dune_pkg/rev_store.ml index ee9f6680ac1..7f1fbdfd5a2 100644 --- a/src/dune_pkg/rev_store.ml +++ b/src/dune_pkg/rev_store.ml @@ -48,13 +48,19 @@ let show { dir } (Rev rev) path = let load_or_create ~dir = let t = { dir } in - (* TODO might as well double check it's a directory *) - match Path.exists dir with - | true -> Fiber.return t - | false -> - Path.mkdir_p dir; - let+ () = run t [ "init"; "--bare" ] in - t + let* () = Fiber.return () in + let+ () = + match Fpath.mkdir_p (Path.to_string dir) with + | Already_exists -> Fiber.return () + | Created -> run t [ "init"; "--bare" ] + | exception Unix.Unix_error (e, x, y) -> + User_error.raise + [ Pp.textf "%s isn't a directory" (Path.to_string_maybe_quoted dir) + ; Pp.textf "reason: %s" (Unix_error.Detailed.to_string_hum (e, x, y)) + ] + ~hints:[ Pp.text "delete this file or check its permissions" ] + in + t ;; module Remote = struct