From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id uH/xIcP5c2ftbAEA62LTzQ:P1 (envelope-from ) for ; Tue, 31 Dec 2024 14:03:47 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id uH/xIcP5c2ftbAEA62LTzQ (envelope-from ) for ; Tue, 31 Dec 2024 15:03:47 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=posteo.de header.s=2017 header.b=ne3zVCAX; spf=pass (aspmx1.migadu.com: domain of "help-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="help-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.de (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1735653827; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=OTA9ixnIqV8PjhfmQFzYHaSzcyurl0gLx0ANby5HXvc=; b=REKb3xEiObNXUwrZasCPjtnBgB0TP681VoaieJrm3E5nHCREep1DKAUDN1t5Zo5Z116rMt PB54cPKJ/iSQlqqCscUeONk5unS0M6oIIV41kpKZ9DRTk/wQu756Rstf2kiLi/7fOwPLW2 7M0iSqZkBjFumRqYM8GJ0Wg18CXYTEKgvchSwekLnp++18kXSUXq4D+sebM2DQBvHF6Ohg S32qQo5orGsWrpliBg8s+lVGeUVoMturfABVbadlLtFsg9Sds5FSRgyDy1429PpBHYtLy/ lMwh/RdmEnZcY49sdVN4pV7B1t25lOAuUzQzqG70FZKfdKX8Lyt7tCg4+mCeZA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=posteo.de header.s=2017 header.b=ne3zVCAX; spf=pass (aspmx1.migadu.com: domain of "help-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="help-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.de (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1735653827; a=rsa-sha256; cv=none; b=sgEG8X0pEMRHyYUZeX51g/bGpXbDsqTXXe4n51dsMzPSLQXcWvZQ45I/s4bNUeJY2zpZ7z WE9K1mWUR5UYMVAXam1DWJuvZPBnNfbGHbvo2mxhAjF6pmeBDFMCP6l1l9/EW7Gh/1lfZZ ID0bU3R5PM5TDcITa76hUaPWRh8IT+NoeVPFZmGi25Vf0FbIH+A80qhsXao6MqHrJ/X4yr nb89oyUY7mp1XnIJ8qysR44yFB+JMNvB++sL5q8OpHo0oGZuyJf3fI4hdgxZbz1He0h03Z XJCSzDahDZXq5xsnYW49pbO3WE8TVyqGxPQ5B9v0Eh3N/Yc7O7G0wl8hwB1mHA== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 326C479763 for ; Tue, 31 Dec 2024 15:03:47 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tScpv-0003nY-JG; Tue, 31 Dec 2024 09:03:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tScpu-0003nM-LO for help-guix@gnu.org; Tue, 31 Dec 2024 09:03:06 -0500 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tScpq-00072x-Ka for help-guix@gnu.org; Tue, 31 Dec 2024 09:03:06 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 93AC1240027 for ; Tue, 31 Dec 2024 15:03:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1735653780; bh=LwAXLOF64X9DzpMFlCCDjLrHSVrD9rWRH+tK4mz//NY=; h=Content-Type:Message-ID:Date:MIME-Version:Subject:From:Cc:From; b=ne3zVCAX3OFXd0K3NIaTzUcvMipdZVSye2nGjtnI3OStIxSv8RFlPa8M3nweOPZ2w nIhcb7uyEW2w5YYlisi/wyY6wKOzGx/bcpLWcSmSJlKEG25ge5ZsNMEgLkmxr7Ksxf nf2GrMHeykewFoJlLR9UkZIPL9jqr1MqpmsiXkY4fBs4fKb0AQQfYr+5Pcwv+tVn+Q ZjUw0FDj+Q6C1DjNsC+K5QkV6HJnp7/o3NReXYxYkRPMAjcyW8AzwrS88kfp8AQgAN ggN66jUlpZdMvGYUhh2ZWuqmfPbJxbwHFhGwFXlxTiRE62ZG+2tVokCH0AT35LPT3r RCIOLyk2gjxyQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4YMvnJ1LXMz9rxL for ; Tue, 31 Dec 2024 15:03:00 +0100 (CET) Message-ID: <6953f50a-d842-43b5-a356-8bd5d2aa5383@posteo.de> Date: Tue, 31 Dec 2024 14:02:59 +0000 MIME-Version: 1.0 Subject: Re: OCaml package `ocaml-zarith` not working / Guix installed `ocamlc` not picking up installed libraries (addendum 2 - using guix profiles) From: Zelphir Kaltstahl Cc: help-guix References: <62213a9d-3bab-4f0f-bd7b-9a98b880ae0d@posteo.de> Content-Language: en-US In-Reply-To: Received-SPF: pass client-ip=185.67.36.65; envelope-from=zelphirkaltstahl@posteo.de; helo=mout01.posteo.de X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, MISSING_HEADERS=1.021, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: help-guix@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+larch=yhetil.org@gnu.org Sender: help-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Queue-Id: 326C479763 X-Migadu-Scanner: mx13.migadu.com X-Migadu-Spam-Score: 1.21 X-Spam-Score: 1.21 X-TUID: XMOPQS6CZePp On 30.12.24 18:53, Zelphir Kaltstahl wrote: > 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. > Update: I tried using guix profiles, hoping, that with profiles and a predictable path (and PATH) things would be different. Here is my setup. ~~~~guix-env/manifest.scm~~~~ (specifications->manifest '("emacs" ;; PROGRAMMING LANGUAGE - OCAML "ocaml@4.14.1" "ocaml-utop" "dune" ;; "opam" "ocaml-zarith" ... (more packages) ... )) ~~~~ ~~~~guix-env/channels.scm~~~~ (list (channel (name 'guix) (url"https://git.savannah.gnu.org/git/guix.git") (branch "master") (commit "c302b7a5966908b3a5db1ef3ccd3af460b847675") (introduction (make-channel-introduction "9edb3f66fd807b096b48283debdcddccfea34bad" (openpgp-fingerprint "BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA"))))) ~~~~ ~~~~command creating guix profile~~~~ $ GUIX_PROFILE="/home/user/dev/ocaml/ocaml-examples/book-ocaml-programming/guix-profile" $ echo $GUIX_PROFILE /home/xiaolong/dev/ocaml/ocaml-examples/book-ocaml-programming/guix-profile $ GUIX_PROFILE="${GUIX_PROFILE}" guix time-machine --channels=guix-env/channels.scm -- package --manifest=guix-env/manifest.scm --profile=guix-profile guix package: warning: Consider running 'guix pull' followed by 'guix package -u' to get up-to-date packages and security updates. The following packages will be installed: ... (more packages) ... dune 3.11.0 emacs 29.4 ... (more packages) ... ocaml 4.14.1 ocaml-utop 2.10.0 ocaml-zarith 1.12 ... (more packages) ... hint: Consider setting the necessary environment variables by running: GUIX_PROFILE="/home/user/dev/ocaml/ocaml-examples/book-ocaml-programming/guix-profile" . "$GUIX_PROFILE/etc/profile" Alternately, see `guix package --search-paths -p "/home/user/dev/ocaml/ocaml-examples/book-ocaml-programming/guix-profile"'. ~~~~ ~~~~command activating guix profile $ GUIX_PROFILE="/home/user/dev/ocaml/ocaml-examples/book-ocaml-programming/guix-profile" $ . "$GUIX_PROFILE/etc/profile" $ command -V ocaml ocaml is /home/user/dev/ocaml/ocaml-examples/book-ocaml-programming/guix-profile/bin/ocaml $ command -V ocamlc ocamlc is /home/user/dev/ocaml/ocaml-examples/book-ocaml-programming/guix-profile/bin/ocamlc ~~~~ ~~~~command running ocaml after activating guix profile~~~~ $ ocamlc -o ex-006-functions/main2.byte ex-006-functions/main2.ml File "ex-006-functions/main2.ml", line 1, characters 5-6: 1 | open Z ^ Error: Unbound module Z ~~~~ So it even with guix profile it does not work and there is no difference in the error when using guix shell and guix profile. This makes me wonder then, how anyone is using any guix package that is named `ocaml-...`. `ocamlc` does not pick them up, so they seem unusable, unless one uses REPL workflow with utop. But in my opinion REPL workflow, while nice when familiar with it, is still not a replacement for having the compiler work correctly with installed libraries. I am for now at a loss how to proceed, except for postponing the usage of libraries not part of the Ocaml distribution entirely. But sooner or later this will come up and then I will be screwed. What I would like to have as a result at the end is a Makefile, that takes care of all the guix incantations, so that I don't have to construct long commands by hand or must rely on command history (happens that I work on another machine for example). This Makefile should simply activate (source) the guix profile, compile the code (impossible due to the described issue) and run the compiled file. Of course I would like to benefit from the reproducible nature of having a guix shell or guix profile. That is why I am even doing all this in the first place. Any machine with working guix package manager I use, I should be able to run the code on in a convenient way, not wanting to setup all the tooling over and over again, and being sure, that I will get reproducible results. Best regards, Zelphir