On 12/3/25 17:01, Gary Johnson wrote:
Okay, this is the source of the problems you are running into. I ran into this
same issue earlier this year when building Python projects with Guix.
Here's what's happening:
1. The `guix shell` command is reading this manifest, building these packages and their
dependencies into the /gnu/store, and then creating an ephemeral profile that links these packages
into it. It also sets various environment variables in your shell to "activate" this
profile. The set of environment variables that it sets are specified in "search-paths"
fields within these packages' Guile definitions.
2. When you enter your bash shell and run `ocaml`, your shell checks the PATH
environment variable for an ocaml executable, which it finds in your ephemeral
profile. This [email protected] as you have noticed.
3. However, when you run `require "zarith"` within the ocaml shell, the ocaml
executable then checks the OCAMLPATH and CAML_LD_LIBRARY_PATH environment variables to
locate the zarith library. As you noted, it finds a version that is compiled for an
earlier version of ocaml.
4. You also noticed that when you run `utop`, you land in an environment
powered by ocaml 4.14.1.
5. This is because the ocaml-utop, ocaml-findlib, and ocaml-zarith packages are
all built [email protected]. Why? Because that is the ocaml package specified in
their actual Guile package definitions.
So you have basically two options to correct your environment:
Option 1. Just include the "ocaml" package in your manifest.scm file. This will
use the default ocaml package, which [email protected] in your current Guix commit.
Option 2. Create updated package definitions for ocaml-utop, ocaml-findlib, and
ocaml-zarith, which explicitly [email protected] in their build procedures. NOTE:
You will also need to do this recursively for all of their dependencies. There
are functions and command line options for doing this recursively though, so
you'll need to check the package transformations section of the Guix info
manual.
Alright, that's it for now. Good luck and happy hacking!
~Gary
Hi Gary!
Thank you for the detailed explanation of what is going on.
I think, I am too noob at updating the dependencies in Guix. Am I understanding
it correctly, that I would have to run my own channel with changed definition in
that case, or edit/change the definitions in my local Guix? I once used a VM to
trying to test my own package, but failed to update my own package definition
for a guile package. I am not sure changing my local guix is a good idea,
because then I would be running something that diverges from official guix and I
might get problems when updating? Or I would have to engage in the process of
getting these updates upstreamed into guix. I am pretty much an Ocaml noob. I
think, that I am not the right person to be managing Ocaml packages, with my
very limited knowledge about Ocaml.
So for now I think the other option, using an older Ocaml, might be the simplest
way.
Including merely "ocaml" in my `manifest.scm` did not help. (See my other
response to Reza on this mailing list.)
However, I tried to pin it to "[email protected]", and when I run `make main` then,
it works, after again building a new guix shell:
~~~~ ocamlfind ocamlc -package zarith -linkpkg -o main.byte main.ml substitute:
looking for substitutes on 'https://bordeaux.guix.gnu.org'... 100.0% 11.6 MB
will be downloaded bash-minimal-5.2.37-doc 313KiB 1.4MiB/s 00:00
▕██████████████████▏ 100.0%substitute: looking for substitutes on
'https://bordeaux.guix.gnu.org'... 100.0% 29.4 MB will be downloaded
glibc-2.41-static 1.5MiB 3.8MiB/s 00:00 ▕██████████████████▏ 100.0%
glibc-2.41-debug 17.8MiB 14.1MiB/s 00:01 ▕██████████████████▏ 100.0%substitute:
looking for substitutes on 'https://bordeaux.guix.gnu.org'... 100.0% 1.1 MB will
be downloaded bash-static-5.2.37-doc 313KiB 1.4MiB/s 00:00 ▕██████████████████▏
100.0%substitute: looking for substitutes on 'https://bordeaux.guix.gnu.org'...
100.0% 0.1 MB will be downloaded zlib-1.3.1-static 54KiB 750KiB/s 00:00
▕██████████████████▏ 100.0%substitute: looking for substitutes on
'https://bordeaux.guix.gnu.org'... 100.0% 0.7 MB will be downloaded
gmp-6.3.0-debug 83KiB 865KiB/s 00:00 ▕██████████████████▏ 100.0%substitute:
looking for substitutes on 'https://bordeaux.guix.gnu.org'... 100.0% The
following derivation will be built:
/gnu/store/r31aphg4pzdmzjs82dfqza6qgp7qj9nr-profile.drv 10.0 MB will be
downloaded module-import-compiled 107KiB 1.1MiB/s 00:00 ▕██████████████████▏
100.0% libffi-3.4.6 57KiB 717KiB/s 00:00 ▕██████████████████▏ 100.0%
libfontenc-1.1.8 14KiB 1.4MiB/s 00:00 ▕██████████████████▏ 100.0% libgc-8.2.8
220KiB 1.6MiB/s 00:00 ▕██████████████████▏ 100.0% libunistring-1.3 570KiB
4.3MiB/s 00:00 ▕██████████████████▏ 100.0% mkfontscale-1.2.3 20KiB 2.3MiB/s
00:00 ▕██████████████████▏ 100.0% module-import-compiled 48KiB 5.0MiB/s 00:00
▕██████████████████▏ 100.0% mkfontdir-1.0.7 4KiB 2.6MiB/s 00:00
▕██████████████████▏ 100.0% module-import-compiled 58KiB 1.1MiB/s 00:00
▕██████████████████▏ 100.0% pkg-config-0.29.2 193KiB 8.6MiB/s 00:00
▕██████████████████▏ 100.0% texinfo-6.8 1.3MiB 7.6MiB/s 00:00
▕██████████████████▏ 100.0% guile-3.0.9 8.1MiB 22.6MiB/s 00:00
▕██████████████████▏ 100.0%building CA certificate bundle... listing Emacs
sub-directories... building fonts directory... building directory of Info
manuals... building profile with 7 packages... guix shell: checking the
environment variables visible from shell '/bin/bash'... guix shell: All is good!
The shell gets correct environment variables. + ocamlfind ocamlc -package zarith
-linkpkg -o main.byte main.ml findlib: [WARNING] Package unix has multiple
definitions in
/gnu/store/2433qxmbnypskfhgjbmmbzdrb3yhn187-profile/lib/ocaml/site-lib/unix/META,
/gnu/store/yjik976n23235nhkr0amkrymb6kyfkxs-ocaml-findlib-1.9.5/lib/ocaml/site-lib/unix/META
findlib: [WARNING] Package threads has multiple definitions in
/gnu/store/2433qxmbnypskfhgjbmmbzdrb3yhn187-profile/lib/ocaml/site-lib/threads/META,
/gnu/store/yjik976n23235nhkr0amkrymb6kyfkxs-ocaml-findlib-1.9.5/lib/ocaml/site-lib/threads/META
./main.byte guix shell: checking the environment variables visible from shell
'/bin/bash'... guix shell: All is good! The shell gets correct environment
variables. + ./main.byte ~~~~
Still a bit worrisome, that `findlib` finds multiple definitions. But apparently
things compile to a .byte file.
Best regards, Zelphir
--
repositories:https://codeberg.org/ZelphirKaltstahl