aantron / dream

Tidy, feature-complete Web framework

Home Page:https://aantron.github.io/dream/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Library "caqti-lwt.unix" not found

shakthimaan opened this issue · comments

I am trying the test the f-static example, and it fails with the following error:

$ dune exec ./static.exe 
Entering directory '/home/guest/dream'
File "src/sql/dune", line 7, characters 2-16:
7 |   caqti-lwt.unix
      ^^^^^^^^^^^^^^
Error: Library "caqti-lwt.unix" not found.
-> required by library "dream.sql" in _build/default/src/sql
-> required by executable static in example/f-static/dune:2
-> required by _build/default/example/f-static/static.exe

I have already setup the 5.1.0 switch:

$ opam switch
#   switch                                                  compiler                   description
->  /home/guest/dream/example/f-static  ocaml-base-compiler.5.1.0  /home/guest/dream/example/f-static
...

The dependencies for f-static has also been installed:

f-static$ opam install --deps-only --yes . 
[f-static.~dev] synchronised (no changes)

What am I missing?

The TL;DR for this case is you need to add --root .:

dune exec ./static.exe --root .

So:

git clone git@github.com:aantron/dream.git --recursive
cd dream
cd example/f-static
opam switch create . 5.1.0 --no-install
eval $(opam env)
opam install --deps-only .
dune exec ./static.exe --root .

The reason for this is you are running the example from within what looks like a Dream development clone, which has different dependencies at this point that the latest release, 1.0.0~alpha5. opam install --deps-only . in the clone root directory would have installed development Dream's current dependencies.

dune exec ./static.exe without --root . seems to decide to compile the example against the Dream development clone in the outer directories, or at least walks its dependencies, even though that's clearly not the intent in your workflow. So you need to give Dune the --root . flag to restrict it to the example's directory, which forces Dune to look at the Dream 1.0.0~alpha5 release that is installed in your local switch instead.

I'll think about how to make this less error-prone. Probably by adding the --root . flags back into all the instructions. I wrongly thought that it's safe to remove them.

Thanks for the report!

Thank you for the detailed instructions and explanation. I was able to follow the above steps to run the server, and wget localhost:8080/static/dune.

Great! Glad it's working! I'm going to reopen open this as a reminder for myself to edit the instructions in the examples.