Zelphir Kaltstahl <[email protected]> writes:

> Hello Guix Users!

Hi, Guix Hacker!

> In the past I thought I had it figured out, thanks to help from
> someone on the mailing list, how to run Ocaml projects in a
> reproducible (hashes/checksums verified!) way.
>
> 8<----------------------------------------------------------------
>
> (1) guix-env/channels.scm: Specifying the exact guix channel that is
> used, and thereby locking down hashes, which are specified in the guix
> repository itself.
>
> ~~~~
> (list (channel
>         (name 'guix)
>         (url"https://git.guix.gnu.org/guix.git";)
>         (branch "master")
>         (commit
>           "7c6d8a6224cf3209efa179dbe1509759a580cb05")
>         (introduction
>           (make-channel-introduction
>             "9edb3f66fd807b096b48283debdcddccfea34bad"
>             (openpgp-fingerprint
>               "BBB0 2DDF 2CEA F6A8 0D1D  E643 A2A0 6DF2 A33A 54FA")))))
> ~~~~

This looks good to me.

> (2) guix-env/manifest.scm: Specifying the package, that I want to use
> for my project.
>
> ~~~~
> (specifications->manifest
>  '("[email protected]"
>    "ocaml-utop"
>    "dune"
>    "bash"
>    "make"
>    "ocaml-findlib"
>    "ocaml-zarith"))
> ~~~~

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 is [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 with [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 is [email protected] in your current Guix 
commit.

Option 2. Create updated package definitions for ocaml-utop, ocaml-findlib, and 
ocaml-zarith, which explicitly use [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

-- 
GPG Key ID: C4FBEDBD
Use `gpg --search-keys [email protected]' to find me
Protect yourself from surveillance: https://emailselfdefense.fsf.org
=======================================================================
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments

Why is HTML email a security nightmare? See https://useplaintext.email/

Please avoid sending me MS-Office attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html

Reply via email to