Skip to content

exception Invalid_argument("Sync.pull_exn: Handshake got an error") when using Sync #2319

@kentookura

Description

@kentookura

Hello,
I have the following code which raises an inscrutable error:

open Lwt.Syntax

module Store = Irmin_git_unix.FS.KV(Irmin.Contents.String)
module Info = Irmin_unix.Info(Store.Info)
module Sync = Irmin.Sync.Make(Store)

module Config = struct
  let root = "/tmp/irmin/test"
  
  let init () =
    let _ = Sys.command (Printf.sprintf "rm -rf %s" root) in
    let _ = Sys.command (Printf.sprintf "mkdir -p %s" root) in
    Irmin.Backend.Watch.set_listen_dir_hook Irmin_watcher.hook
end

let main_branch config =
  let* repo = Store.Repo.v config in
  Store.main repo

let main () =
  Config.init();
  let config  = Irmin_git.config Config.root in
  let* repo = Store.Repo.v config in
  let* upstream = Store.remote "https://git.sr.ht/~jonsterling/public-trees" in
  let* t = main_branch config in
  let* _ = Sync.pull_exn t upstream `Set in
  let+ list = Store.list t [] in
  list |> 
    List.iter (fun (_, store_tree) ->
        match Store.Tree.destruct store_tree with
        | `Contents _ -> Printf.printf "FILE \n"
        | `Node _ -> Printf.printf "DIR \n" ) 


let () = Lwt_main.run (main ())
File "test/dune", line 2, characters 14-19:
2 |  (names parse store)
                  ^^^^^
Fatal error: exception Invalid_argument("Sync.pull_exn: Handshake got an error")
Raised at Lwt.Miscellaneous.poll in file "src/core/lwt.ml", line 3123, characters 20-29
Called from Lwt_main.run.run_loop in file "src/unix/lwt_main.ml", line 27, characters 10-20
Called from Lwt_main.run in file "src/unix/lwt_main.ml", line 106, characters 8-13
Re-raised at Lwt_main.run in file "src/unix/lwt_main.ml", line 112, characters 4-13
Called from Dune__exe__Store in file "test/store.ml", line 41, characters 9-31

Now, the error actually gets raised by ocaml-git, so perhaps I should rather report it in that repo. Nontheless, the code is virtually the same as the one found in the sync example.

Some notes:

I'll try to run my code on my native linux machine. If this ends up working, I can confirm that there is a bug when running ocaml-git on WSL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions