help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OCaml package `ocaml-zarith` not working / Guix installed `ocamlc` n


From: Julien Lepiller
Subject: Re: OCaml package `ocaml-zarith` not working / Guix installed `ocamlc` not picking up installed libraries (addendum 1)
Date: Mon, 30 Dec 2024 20:33:48 +0100
User-agent: K-9 Mail for Android

That might be a mismatch between ocaml (latest version is ocaml 5) and tge 
libraries which are currently built with ocaml4. If you try the same with 
ocaml@4, does it work?

Le 30 décembre 2024 18:53:06 GMT+01:00, Zelphir Kaltstahl 
<zelphirkaltstahl@posteo.de> a écrit :
>On 30.12.24 18:50, Zelphir Kaltstahl wrote:
>> 
>> Hello Guix users,
>> 
>> I am facing a problem trying to use Guix to install Ocaml packages.
>> 
>> I was implementing a simple recursive factorial function, as part of 
>> learning the language, and tested what would happen, if I calculated 
>> factorial of 100 ... Result: 0. "Ah!" I thought, "all I need to do is get 
>> that Zarith package I have been reading about before, and import that in my 
>> code!". So I added it to my manifest.scm file, which I use for a `guix 
>> shell`, and expected the Ocaml compiler to naturally pick up packages 
>> installed via guix, since the Ocaml compiler ocamlc is also installed using 
>> guix. However, it seems this is dysfunctional currently and ocamlc does not 
>> realize that the library is in fact installed. I am not sure where it is 
>> looking for libraries.
>> 
>> Here is how to reproduce:
>> 
>> ~~~~guix-env/channels.scm~~~~
>> (list (channel
>>          (name 'guix)
>>          (url"https://git.savannah.gnu.org/git/guix.git";)
>>          (branch "master")
>>          (commit
>>            "4473f8ae902c2192cab6919363a9101ce9861e45")
>>          (introduction
>>            (make-channel-introduction
>>              "9edb3f66fd807b096b48283debdcddccfea34bad"
>>              (openpgp-fingerprint
>>                "BBB0 2DDF 2CEA F6A8 0D1D  E643 A2A0 6DF2 A33A 54FA")))))
>> ~~~~
>> 
>> ~~~~guix-env/manifest.scm~~~~
>> (specifications->manifest
>>   '("ocaml"
>>     "ocaml-utop"
>>     "dune"
>>     ;; "opam"  ; using guix to install packages, should not need opam
>>     "bash"
>>     "ocaml-zarith"))
>> ~~~~
>> 
>> ~~~~main.ml~~~~
>> open Z
>> 
>> let factorial n =
>>    let rec iter n =
>>      if n < (of_int 2)
>>      then of_int 1
>>      else mul n (iter (sub n (of_int 1)))
>>    in
>>      iter (of_int n)
>> 
>> 
>> let _ = 5 |> factorial |> to_string |> print_endline
>> let _ = 100 |> factorial |> to_string |> print_endline
>> ~~~~
>> 
>> ~~~~command~~~~
>> guix time-machine --channels=guix-env/channels.scm -- shell --check 
>> --manifest=guix-env/manifest.scm -- bash -c 'ocamlc -c main.ml -o main.byte'
>> 
>> guix shell: checking the environment variables visible from shell 
>> '/bin/bash'...
>> guix shell: All is good!  The shell gets correct environment variables.
>> File "main.ml", line 1, characters 5-6:
>> 1 | open Z
>>           ^
>> Error: Unbound module Z
>> ~~~~
>
>I would also like to add, that utop _does_ pick up the library and that in 
>utop I can:
>
>~~~~in utop~~~~
>#require "zarith";;
>~~~~
>
>And work with its functions.
>
>So this really seems to be about ocamlc.
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]