GNU bug report logs -
#58250
guix import json: GUIX_PACKAGE_PATH -- no code for module
Previous Next
To reply to this bug, email your comments to 58250 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-guix <at> gnu.org
:
bug#58250
; Package
guix
.
(Sun, 02 Oct 2022 14:27:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
itd <itd <at> net.in.tum.de>
:
New bug report received and forwarded. Copy sent to
bug-guix <at> gnu.org
.
(Sun, 02 Oct 2022 14:27:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi,
I'm having an issue with the JSON importer. The following example
attempts to illustrate the problem:
> $ cd $(mktemp -d) # -> /tmp/tmp.J3f9qsyDIL
> /tmp/tmp.J3f9qsyDIL$ cat myhello.json
> {
> "name": "myhello",
> "version": "2.10",
> "source": "mirror://gnu/hello/hello-2.10.tar.gz",
> "build-system": "gnu",
> "license": "GPL-3.0+",
> "native-inputs": ["gettext", "myotherhello"]
> }
> /tmp/tmp.J3f9qsyDIL$ cat non-gnu.scm
> (define-module (non-gnu)
> #:use-module (gnu packages base)
> #:use-module (guix packages))
>
> (define-public myotherhello
> (package (inherit hello) (name "myotherhello")))
As expected, both `hello` and `myotherhello` are found by `guix search
-L /tmp/tmp.J3f9qsyDIL hello`:
> name: hello
> ...
> location: gnu/packages/base.scm:86:2
> ...
> name: myotherhello
> ...
> location: /tmp/tmp.J3f9qsyDIL/non-gnu.scm:6:2
But importing `myhello` fails:
> /tmp/tmp.J3f9qsyDIL$ export GUIX_PACKAGE_PATH=/tmp/tmp.J3f9qsyDIL/
> /tmp/tmp.J3f9qsyDIL$ guix import json myhello.json
>
> Starting download of /tmp/guix-file.bQ5VSS
> From https://ftpmirror.gnu.org/gnu/hello/hello-2.10.tar.gz...
> following redirection to `https://gnu.askapache.com/hello/hello-2.10.tar.gz'...
> …10.tar.gz 709KiB 671KiB/s 00:01 [##################] 100.0%
> Backtrace:
> 14 (primitive-load "/home/itd/.config/guix/current/bin/…")
> In guix/ui.scm:
> 2263:7 13 (run-guix . _)
> 2226:10 12 (run-guix-command _ . _)
> In guix/scripts/import.scm:
> 92:11 11 (guix-import . _)
> In ice-9/boot-9.scm:
> 1747:15 10 (with-exception-handler #<procedure 7efce407acf0 at ic…> …)
> In guix/scripts/import/json.scm:
> 91:16 9 (_)
> In ice-9/boot-9.scm:
> 1747:15 8 (with-exception-handler #<procedure 7efce407acc0 at ic…> …)
> In guix/import/json.scm:
> 86:18 7 (_)
> In guix/import/print.scm:
> 220:37 6 (package->code _)
> 161:17 5 (inputs->code (("gettext" #<package gettext <at> 0.21 g…>) #))
> In srfi/srfi-1.scm:
> 586:29 4 (map1 (("gettext" #<package gettext <at> 0.21 gnu/packa…>) #))
> 586:17 3 (map1 (("myotherhello" #<package myotherhello <at> 2.12.1…>)))
> In guix/import/print.scm:
> 164:40 2 (_ _)
> 60:31 1 (variable-name _ (#{}# tmp tmp.J3f9qsyDIL non-gnu))
> In ice-9/boot-9.scm:
> 3330:6 0 (resolve-interface (#{}# tmp tmp.J3f9qsyDIL non-gnu) # _ …)
>
> ice-9/boot-9.scm:3330:6: In procedure resolve-interface:
> no code for module (#{}# tmp tmp.J3f9qsyDIL non-gnu)
One can influence the name of the mentioned module via
GUIX_PACKAGE_PATH, e.g.:
> /tmp/tmp.J3f9qsyDIL$ export GUIX_PACKAGE_PATH=.
> /tmp/tmp.J3f9qsyDIL$ guix import json myhello.json
> ...
> ice-9/boot-9.scm:3330:6: In procedure resolve-interface:
> no code for module (#{.}# non-gnu)
But the issue remains.
Suspected cause: the value of GUIX_PACKAGE_PATH is considered part of
the module name but shouldn't. This results in an unexpected module
name / missing module. Idea: when constructing the module name from the
file name, this prefix should be removed.
Regards
itd
Information forwarded
to
bug-guix <at> gnu.org
:
bug#58250
; Package
guix
.
(Sun, 02 Oct 2022 14:36:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 58250 <at> debbugs.gnu.org (full text, mbox):
* guix/modules.scm (file-name->module-name): Ignore load path prefix
when building module name.
---
It was mentioned on IRC, that (guix modules)'s file-name->module-name
might be function to be used by the JSON importer (and fixed if needed).
This patch attempts to implement the idea from the bug report.
guix/modules.scm | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/guix/modules.scm b/guix/modules.scm
index 61bc8e1978..269d52ae1e 100644
--- a/guix/modules.scm
+++ b/guix/modules.scm
@@ -100,11 +100,23 @@ (define module-file-dependencies
'()))))))
(define file-name->module-name
- (let ((not-slash (char-set-complement (char-set #\/))))
+ (let ((not-slash (char-set-complement (char-set #\/)))
+ (load-path-prefix-length
+ (lambda (file)
+ ;; Length of the longest prefix among all given load paths.
+ (apply max (map
+ (lambda (path) (if (string-prefix? path file)
+ (string-length path)
+ 0))
+ %load-path)))))
(lambda (file)
"Return the module name (a list of symbols) corresponding to FILE."
(map string->symbol
- (string-tokenize (string-drop-right file 4) not-slash)))))
+ (string-tokenize
+ (string-drop
+ (string-drop-right file 4)
+ (load-path-prefix-length file))
+ not-slash)))))
(define (module-name->file-name module)
"Return the file name for MODULE."
base-commit: ae221813745783ef1b7eee47561a2208cd5ad512
--
2.37.3
Information forwarded
to
bug-guix <at> gnu.org
:
bug#58250
; Package
guix
.
(Sun, 02 Oct 2022 14:39:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 58250 <at> debbugs.gnu.org (full text, mbox):
* guix/import/print.scm (package->code)[package-module-name]: Use
file-name->module-name to build the package module name.
---
This patch updates the JSON importer to use (guix modules)'s
file-name->module-name to determine the module name.
guix/import/print.scm | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/guix/import/print.scm b/guix/import/print.scm
index 2f54adbd8c..04e6b0a7b1 100644
--- a/guix/import/print.scm
+++ b/guix/import/print.scm
@@ -21,6 +21,7 @@ (define-module (guix import print)
#:use-module (guix base32)
#:use-module (guix utils)
#:use-module (guix licenses)
+ #:use-module (guix modules)
#:use-module (guix packages)
#:use-module (guix search-paths)
#:use-module (guix build-system)
@@ -45,10 +46,7 @@ (define (package->code package)
when evaluated."
;; The module in which the package PKG is defined
(define (package-module-name pkg)
- (map string->symbol
- (string-split (string-drop-right
- (location-file (package-location pkg)) 4)
- #\/)))
+ (file-name->module-name (location-file (package-location pkg))))
;; Return the first candidate variable name that is bound to VAL.
(define (variable-name val mod)
--
2.37.3
Information forwarded
to
bug-guix <at> gnu.org
:
bug#58250
; Package
guix
.
(Fri, 23 Dec 2022 13:50:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 58250 <at> debbugs.gnu.org (full text, mbox):
Hi,
itd <itd <at> net.in.tum.de> skribis:
> * guix/modules.scm (file-name->module-name): Ignore load path prefix
> when building module name.
> ---
> It was mentioned on IRC, that (guix modules)'s file-name->module-name
> might be function to be used by the JSON importer (and fixed if needed).
> This patch attempts to implement the idea from the bug report.
At first sight I believe the fix should be in ‘package->code’, not in
(guix modules).
(guix modules) is quite sensitive so in general we should refrain from
changing the semantics of its procedures. In this case,
‘file-name->module-name’ expects a file name relative to a search path
entry.
HTH,
Ludo’.
Information forwarded
to
bug-guix <at> gnu.org
:
bug#58250
; Package
guix
.
(Fri, 23 Dec 2022 13:52:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 58250 <at> debbugs.gnu.org (full text, mbox):
itd <itd <at> net.in.tum.de> skribis:
> * guix/import/print.scm (package->code)[package-module-name]: Use
> file-name->module-name to build the package module name.
> ---
> This patch updates the JSON importer to use (guix modules)'s
> file-name->module-name to determine the module name.
>
> guix/import/print.scm | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/guix/import/print.scm b/guix/import/print.scm
> index 2f54adbd8c..04e6b0a7b1 100644
> --- a/guix/import/print.scm
> +++ b/guix/import/print.scm
> @@ -21,6 +21,7 @@ (define-module (guix import print)
> #:use-module (guix base32)
> #:use-module (guix utils)
> #:use-module (guix licenses)
> + #:use-module (guix modules)
> #:use-module (guix packages)
> #:use-module (guix search-paths)
> #:use-module (guix build-system)
> @@ -45,10 +46,7 @@ (define (package->code package)
> when evaluated."
> ;; The module in which the package PKG is defined
> (define (package-module-name pkg)
> - (map string->symbol
> - (string-split (string-drop-right
> - (location-file (package-location pkg)) 4)
> - #\/)))
> + (file-name->module-name (location-file (package-location pkg))))
LGTM!
Ludo'.
This bug report was last modified 2 years and 71 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.