(file-name->module-name (location-file (package-location pkg))) returns wrong module

  • Open
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • Tomas Volf
Owner
unassigned
Submitted by
Tomas Volf
Severity
normal
T
T
Tomas Volf wrote on 7 Jul 18:16 +0200
(address . bug-guix@gnu.org)
Zoq_SpbfnQSd4S-1@ws
Hi,

when I try to use the above, it returns wrong module. The module returned is
prefixed by #{.}# symbol. Full reproducer:

(define-module (xx)
#:use-module (guix)
#:use-module (guix modules)
#:use-module (guix utils))

(define-public pkg
(package
(name "foo")
(version #f)
(source #f)
(build-system #f)
(synopsis #f)
(description #f)
(license #f)
(home-page #f)))

(pk (file-name->module-name (location-file (package-location pkg))))

Now just run it:

$ GUILE_AUTO_COMPILE=0 guile -L . -c '(use-modules (xx))'

;;; ((#{.}# xx))

Notice that the module is not just (xx) as it should have been.

The impact of this bug is broken guix pull for my channel (I will work around it
somehow, I hope) but still it would be nice if it worked properly, hence this report.

Have a nice day,
Tomas Volf

--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEt4NJs4wUfTYpiGikL7/ufbZ/wakFAmaKv0oACgkQL7/ufbZ/
wak5XRAAmwnC+HrQOOVvhbtHQcWvexqlrdPjsBDE6UFdlVP3Eq+8nzdPnuI/mhfa
au1muqAC8wJfl1n/dQ+jGVIpt26SGT0TMEHjV+jtJIPvD3zOwZtKivxoVuUrO9Ou
Vboek075m2LL4r3vcxL2DbjY4wmmE6jvrhJBdVxFxw1utURHjwPoJmVwzh/R1O46
EkmWccbUIQv51JgNC0XOEcsD99wQiOHTIRp4Fierh8MwAsDwMl3bO0xxYl5ppcJg
lKdxympnpwt7IB2IiVXYgIQesVmnz1IZ9WuEqS9UNvw9ygaSvLqDOxtzGtRoQj9F
Fcz+2YJrNMuXDBsmPP+g+oKZAhlPmrbVglpCBMdl4ncSoQUZyeS9u6IPRC+/ihNW
nY/8lwKauEmEXAvEXw9NqrEqEcxW+8zvUed4psJZBA0SnjOedPMp0/auMQ1IJtV9
NqGv1M3fpZcJitcgIUvtoWNvl7MFwjD4945ned8Euul9VZB1/r3xXhp3gQ4ULDi7
UEe54fkD++cJtUObDuHHZL1DWjNyPBO2Y6X4rWDuYBQ7CL/+CzCOF93yXdifNd05
C0r53c2CHF4AgTNe4o8rUXWVUEcVGQFVBlVKgzn6sjNOwUr6XaKWu2W2X8sEYL9G
T5laJY7C1Igzkm6v87ubfW+qIUMU3nLwVEcToC5OTyJzX8O7g9s=
=dF7L
-----END PGP SIGNATURE-----


L
L
Ludovic Courtès wrote on 18 Jul 17:34 +0200
(name . Tomas Volf)(address . ~@wolfsden.cz)(address . 71979-done@debbugs.gnu.org)
87ed7qvhn3.fsf@gnu.org
Hi Tomas,

Tomas Volf <~@wolfsden.cz> skribis:

Toggle quote (29 lines)
> when I try to use the above, it returns wrong module. The module returned is
> prefixed by #{.}# symbol. Full reproducer:
>
> (define-module (xx)
> #:use-module (guix)
> #:use-module (guix modules)
> #:use-module (guix utils))
>
> (define-public pkg
> (package
> (name "foo")
> (version #f)
> (source #f)
> (build-system #f)
> (synopsis #f)
> (description #f)
> (license #f)
> (home-page #f)))
>
> (pk (file-name->module-name (location-file (package-location pkg))))
>
> Now just run it:
>
> $ GUILE_AUTO_COMPILE=0 guile -L . -c '(use-modules (xx))'
>
> ;;; ((#{.}# xx))
>
> Notice that the module is not just (xx) as it should have been.

Oh, good catch.

I went ahead and pushed a fix as
e3dfed59d39ac60dd2e2b9ef9f4ef63a2a081f41. Let me know if you find
anything wrong!

Thanks,
Ludo’.
Closed
T
T
Tomas Volf wrote on 18 Jul 23:21 +0200
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 71979@debbugs.gnu.org)
ZpmHXCnJIhmjFftx@ws
Hello Ludo',

On 2024-07-18 17:34:08 +0200, Ludovic Courtès wrote:
Toggle quote (39 lines)
> Hi Tomas,
>
> Tomas Volf <~@wolfsden.cz> skribis:
>
> > when I try to use the above, it returns wrong module. The module returned is
> > prefixed by #{.}# symbol. Full reproducer:
> >
> > (define-module (xx)
> > #:use-module (guix)
> > #:use-module (guix modules)
> > #:use-module (guix utils))
> >
> > (define-public pkg
> > (package
> > (name "foo")
> > (version #f)
> > (source #f)
> > (build-system #f)
> > (synopsis #f)
> > (description #f)
> > (license #f)
> > (home-page #f)))
> >
> > (pk (file-name->module-name (location-file (package-location pkg))))
> >
> > Now just run it:
> >
> > $ GUILE_AUTO_COMPILE=0 guile -L . -c '(use-modules (xx))'
> >
> > ;;; ((#{.}# xx))
> >
> > Notice that the module is not just (xx) as it should have been.
>
> Oh, good catch.
>
> I went ahead and pushed a fix as
> e3dfed59d39ac60dd2e2b9ef9f4ef63a2a081f41. Let me know if you find
> anything wrong!

Thank you for the fix. I can confirm (using the original reproducer) that it
works when run from guix repl:

$ GUILE_AUTO_COMPILE=0 guix repl -qL .
GNU Guile 3.0.9
Copyright (C) 1995-2023 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guix-user)> ,use (xx)

;;; ((xx))

However there seem to be few more edge cases that are still not working.

Dot multiple times:

$ GUILE_AUTO_COMPILE=0 guix repl -qL ././.
GNU Guile 3.0.9
Copyright (C) 1995-2023 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guix-user)> ,use (xx)

;;; ((#{.}# #{.}# xx))

Double-dot:

$ GUILE_AUTO_COMPILE=0 guix repl -qL ../tmp
GNU Guile 3.0.9
Copyright (C) 1995-2023 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guix-user)> ,use (xx)

;;; ((.. tmp xx))

Should I report those as separate bugs? Or do you think I should just re-open
this one?



Side-note: I have to say I am confused about behavior of guix repl with
/dev/stdin. Everything seems to work there:

$ echo '(use-modules (xx))' | GUILE_AUTO_COMPILE=0 guix repl -L . /dev/stdin

;;; ((xx))
$ echo '(use-modules (xx))' | GUILE_AUTO_COMPILE=0 guix repl -L ././. /dev/stdin

;;; ((xx))
$ echo '(use-modules (xx))' | GUILE_AUTO_COMPILE=0 guix repl -L ../tmp /dev/stdin

;;; ((xx))

I have no idea why. I would also try -c as I did in my original reproduces, but
guix repl does not support it (I wonder why).



For completeness' sake I am including original message I wrote before trying
`guix repl' and therefore writing the above text instead:

However I am unsure whether it works. I pulled the Guix channel:

$ guix describe
Generation 1 Jul 18 2024 18:44:20 (current)
guix e3dfed5
branch: master
commit: e3dfed59d39ac60dd2e2b9ef9f4ef63a2a081f41

As far as I can tell that commit should include your fix (or even better, that
commit is your fix). However when I try the reproducer from the original bug
report, I am still getting:

$ GUILE_AUTO_COMPILE=0 guile -L . -c '(use-modules (xx))'

;;; ((#{.}# xx))



Toggle quote (4 lines)
>
> Thanks,
> Ludo’.

--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEt4NJs4wUfTYpiGikL7/ufbZ/wakFAmaZh1sACgkQL7/ufbZ/
wakNxA//VtvQ8D+Y8lvMDhu/GX6LLZyDybDNc05i0zv5KJh9XL92C2K0GvCDUE1Y
G7gYo5G0MRBxbQV/Ze3ju56bDdGitTqSkxAuDNlujP7uQkCBEqJ6xfmzUPskUt8z
gDciLibxIPBFql4vC0keN2L0nPas6HmluiwyLF1A4lVjbHQYnS7Hf9iQOQXjURHL
Lwfad49U7CpXH1Hrt/LW/swDQMhF+WsXfErdw+fZ/l3ptAc7Yesd1fR9QqospKzd
cqcp9Ed9GTP6TG/BTBE7y3XehwbXwFLIklWZuieRv4AwMIPDRH5IAIuIvlur0nm3
f7QcB3aHKsg4MFbsX/2agWEV8GpgaO/o7vKBaAvaKEdknijiVIHGYlEuL0HtxJye
kYuB1fPCwVTjEjnc6loxiPkPVyE3gP3U8Hnwm6siLp3KwUbtXVjEWXhhA1D8hjJY
1daPHv8AYO2XqXzuvTqxfsL0VHAVMqy+uTJPOfa/eF5JVV14uSy8aL+IWwtaCIKe
HnCEIWdG4dqg9yR7C4CLxz0PyHvcte6WwrYcdTr7VELuUNaftTH6jts58Z+zd2ag
Bw8foMvoM09Ubbq5Ezsp/dTtodIr4HNqlbp/VeATmUuFiPaTcCxyzzjj/yodJGnz
7U9Exp15SO0eVN5sYykIreD12NEYQU3uHqMmEtNPfb0a3FdDVPU=
=jG/Z
-----END PGP SIGNATURE-----


T
T
Tomas Volf wrote on 6 Oct 16:48 +0200
control message for bug #71979
(address . control@debbugs.gnu.org)
3092e46d965545b51902e224dd1847b9@wolfsden.cz
unarchive 71979
quit
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 71979@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 71979
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch