paurkedal / ocaml-caqti

Cooperative-threaded access to relational data
https://paurkedal.github.io/ocaml-caqti/index.html
GNU Lesser General Public License v3.0
299 stars 36 forks source link

EIO driver load failure #97

Closed anmonteiro closed 1 year ago

anmonteiro commented 1 year ago

Compare the same 2 programs in Lwt / EIO:

(* LWT *)
let () =
  let uri = Sys.getenv "DB_URI" in
  Lwt_main.run
    ( Caqti_lwt_unix.connect_pool ~max_size:10 (Uri.of_string uri)
    |> Result.get_ok
    |> fun (_ : _ Caqti_lwt_unix.Pool.t) -> Lwt.return_unit )

(* EIO *)
open Eio.Std

let () =
  let uri = Sys.getenv "DB_URI" in
  Eio_main.run (fun env ->
      Switch.run (fun sw ->
          (* let open Lwt.Syntax in *)
          let x =
            Caqti_eio.connect_pool ~max_size:10 ~sw env (Uri.of_string uri)
          in
          ignore @@ Result.get_ok x))

Fatal error: exception Invalidargument("result is Error ")

anmonteiro commented 1 year ago

The error is:

x: Failed to load driver for $DB_URI: Neither caqti-driver-postgresql nor the dynamic linker is linked into the application.

anmonteiro commented 1 year ago

OK This seems to work with caqti-eio.unix instead, but I'm not sure why.

anmonteiro commented 1 year ago
  1. sorry for the noise
  2. this seems to be an issue, still.
anmonteiro commented 1 year ago

And confirmed again it works but I actually need to use the Caqti_eio_unix module. Again, sorry for all the noise.

paurkedal commented 1 year ago

Yes, the unix flavour is needed for drivers based on bindings; PGX is the only driver which works without it.

anmonteiro commented 1 year ago

It looks like the most recent commits address the duplication here? specifically https://github.com/paurkedal/ocaml-caqti/commit/34ea92750b7e85d8bc245deb072e32461a5d9aa9

paurkedal commented 1 year ago

I don't tihnk so. The commit is cosmetic, removing some aliases. One can still use the Caqti_eio.connect_pool and get the same error for non-PGX drivers.