mirage / ocaml-git

Pure OCaml Git format and protocol
ISC License
363 stars 70 forks source link

Sync.fetch raises Mimic error: Handshake got an error #644

Open kentookura opened 2 months ago

kentookura commented 2 months ago

Hello, in the context of using this library via irmin, we've encountered an issue.

The following code fails on both nixOS 24.05 via WSL (@kentookura), and macOS 14.5 (@jonsterling). however @art-w reports the code working on their linux.

(executable (name test) (libraries lwt git-unix git.nss.git))
open Lwt.Syntax
open Lwt.Infix
module Store = Git_unix.Store
module Sync = Git_unix.Sync (Store)
module Uri = Smart_git.Endpoint

let src =
  Uri.of_string "https://git.sr.ht/~jonsterling/public-trees" |> Result.get_ok

let main () =
  let* ctx = Git_unix.ctx (Happy_eyeballs_lwt.create ()) in
  let* store = Store.v Fpath.(v "/tmp" / "gitsync") >|= Result.get_ok in
  let+ result = Sync.fetch ~ctx src store `All in
  match result with
  | Ok (Some (_hash, lst)) ->
      Format.printf "Ok! Some list %#i@." (List.length lst)
  | Ok None -> Format.printf "Ok! None?@."
  | Error (#Mimic.error as e) ->
      Format.printf "Mimic error: %a@." Mimic.pp_error e
  | Error (`Exn e) -> Format.printf "Git error: %s@." (Printexc.to_string e)
  | Error _ -> Format.printf "Git error: <unknown private error tag>@."

let () = Lwt_main.run (main ())
Mimic error: Handshake got an error

Thanks!

https://github.com/mirage/irmin/issues/2319

jonsterling commented 1 month ago

Hi all, I wanted to check if anyone has had a chance to look into this issue — I have some cool experiments I would like to run in connection with the Forester project that are currently blocked on this.

dinosaure commented 1 month ago

You must initialize mirage-crypto-rng.unix at some point. I can reproduce your error and I can fix it also if I add into your code:

let () = Mirage_crypto_rng_unix.initialize (module Mirage_crypto_rng.Fortuna)

I agree that the error is a bit obscur. I will try to understand why mirage-crypto does not show up a message which advise the user to initialize the RNG.