sqlite3-ocaml
sqlite3-ocaml copied to clipboard
Error when building sqlite3-ocaml against custom sqlite build
I have a custom build of sqlite3, built for and installed into in a directory /PREFIX, and made this available via:
export PKG_CONFIG_PATH=/PREFIX/lib/pkgconfig
When now I try opam install sqlite3, the build fails on dependency package conf-sqlite3 with empty logfiles.
The output of pkg-config for the custom build is correct:
$ pkg-config --libs sqlite3
-L/PREFIX/lib -lsqlite3
$ pkg-config --cflags sqlite3
-I/PREFIX/include
Some final observations:
- It doesn't matter whether I use
PKG_CONFIG_PATHorPKG_CONFIG_LIBDIR - It doesn't matter if the custom build is static, shared or both
- When I install the system wide
libsqlite3-devpackage (Debian) and use cleanPKG_CONFIG_*environment variables, everything works
Note that this might be related to https://github.com/ocaml/opam-repository/issues/12923, but here in this ticket the plain -c 4.07.1 OCaml switch was used.
All that the conf-sqlite3 package does is run pkg-config sqlite3 to check its exit code. I suspect, as you do in the related OPAM issue, that maybe the environment variables are not passed on to that command. If that's the case there isn't much I could do about that, this would have to be addressed in OPAM.
As far as I can see, the environment variables are in place.
Summary of the failing command:
$ opam install conf-sqlite3
[ERROR] The compilation of conf-sqlite3 failed at "/.../opam-init/hooks/sandbox.sh build pkg-config
sqlite3".
...
# command ~/.../opam-init/hooks/sandbox.sh build pkg-config sqlite3
# exit-code 1
# env-file ~/.../log/conf-sqlite3-5299-ccabea.env
# output-file ~/.../log/conf-sqlite3-5299-ccabea.out
Error report
┌─ The following actions failed
│ λ build conf-sqlite3 1
└─
╶─ No changes have been performed
The packages you requested declare the following system dependencies. Please make sure they are installed before retrying:
libsqlite3-dev
# Run eval $(opam env) to update the current shell environment
Grep for the PKG_CONFIG envvars:
$ grep PKG_CONFIG ~/.../log/conf-sqlite3-5299-ccabea.env PKG_CONFIG_LIBDIR= PKG_CONFIG_PATH=/...PREFIX.../lib/pkgconfig
The reverse check also works: When installing sqlite3-dev system wide and cleaning the PKG_CONFIG_ environemnt variables, everything works. If I then set PKG_CONFIG_LIBPATH to a bogus value, the build fails. So the environment variables are propagated and do affect the result.
You could try executing pkg-config sqlite3 within the exact same environment. There has to be a way to replicate the problem without going through OPAM. It will likely be quickly apparent what that problem is then.
The problem seems to be with the sandboxing.
- When initializing the OPAM with
--disable-sandboxing, everything works, so this is a possible workaround. - When initializing the OPAM without
--disable-sandboxing, the bug appears, but is still hard to reproduce without OPAM. For example, running the.../sandbox.sh ... pkg-config ...command by hand is successful (exitcode 0).
Strange, not sure what to do about it. I'll leave this open for the while being. Maybe this gets fixed in OPAM, or someone figures out how to improve interaction between this library and OPAM to work around or fix this issue.
I retested with the currently latest OPAM 2.0.3 version, and still observe exactly the same effect as described above.
Which steps are needed to escalate this to the opam and/or opam-sandbox people?
Moreover, are you interested in a set of instructions to reproduce this issue in a fully self-contained directory?
@vog if you have self contained steps to reproduce open an issue on opam's bug tracker.