`guix import go` fails outside of pre-inst-env

  • Done
  • quality assurance status badge
Details
5 participants
  • Josselin Poiret
  • Maxime Devos
  • Tobias Geerinckx-Rice
  • winter
  • Simon Tournier
Owner
unassigned
Submitted by
winter
Severity
normal
W
W
winter wrote on 1 Mar 2023 04:42
(address . bug-guix@gnu.org)
F29B8BFE-A175-4128-8093-4A810681E235@winter.cafe
Hi,

As of commit ec8c7370dfd66136f7cb517d31fa6fda31e2cb74, the following `guix import` invocation fails:

$ guix import go --recursive github.com/tdewolff/minify/v2
Backtrace:
In ice-9/boot-9.scm:
222:29 19 (map1 _)
222:29 18 (map1 _)
222:29 17 (map1 _)
222:29 16 (map1 _)
222:29 15 (map1 _)
222:29 14 (map1 _)
222:29 13 (map1 _)
222:29 12 (map1 _)
222:29 11 (map1 _)
222:17 10 (map1 (((gnu packages check)) ((gnu packages #)) ((…)) …))
3327:17 9 (resolve-interface (gnu packages check) #:select _ # _ # …)
In ice-9/threads.scm:
390:8 8 (_ _)
In ice-9/boot-9.scm:
3253:13 7 (_)
In ice-9/threads.scm:
390:8 6 (_ _)
In ice-9/boot-9.scm:
3544:20 5 (_)
2836:4 4 (save-module-excursion _)
3564:26 3 (_)
In unknown file:
2 (primitive-load-path "gnu/packages/check" #<procedure a…>)
In gnu/packages/check.scm:
1037:13 1 (_)
In ice-9/boot-9.scm:
1685:16 0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
error: go-github-com-robfig-cron: unbound variable

Strangely enough, it does work inside pre-inst-env with that same commit:

$ ./pre-inst-env guix import go --recursive github.com/tdewolff/minify/v2
(define-public go-github-com-djherbis-atime
<...>

I'm very unsure as to why this is happening, as `(gnu packages golang)` is imported in `(gnu packages check)`. Plus, even more weirdly, `guix build` can't find the problematic package, but can build the one that depends on it:

$ guix build go-github-com-robfig-cron-1.2
guix build: error: go-github-com-robfig-cron-1.2: unknown package
$ guix build actionlint
/gnu/store/0nzn1lbq02mfp6ka7z34lp9ly5nhlrv4-actionlint-1.6.23

I'd appreciate any help tracking down what could possibly be wrong here, as it's very puzzling.

Thanks,
Winter
J
J
Josselin Poiret wrote on 1 Mar 2023 10:47
875ybkolb8.fsf@jpoiret.xyz
Hi,

winter--- via Bug reports for GNU Guix <bug-guix@gnu.org> writes:

Toggle quote (14 lines)
> Hi,
>
> As of commit ec8c7370dfd66136f7cb517d31fa6fda31e2cb74, the following `guix import` invocation fails:
>
> $ guix import go --recursive github.com/tdewolff/minify/v2
> [...]
> In gnu/packages/check.scm:
> 1037:13 1 (_)
> In ice-9/boot-9.scm:
> 1685:16 0 (raise-exception _ #:continuable? _)
>
> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
> error: go-github-com-robfig-cron: unbound variable

This is way worse: (gnu packages golang) cannot be loaded at all!
This is caused by a cycle, (gnu packages golang) uses (gnu packages
check) and vice-versa, and go-github-com-robfig-cron is defined in (gnu
packages golang)! So depending on whether you first use (gnu packages
check) or (gnu packages golang), go-github-com-robfig-cron will not have
been defined yet, hence the error.

Using (gnu packages check) then (gnu packages golang) doesn't make the
error appear. The solution imo, esp. since (gnu packages check) already
uses (gnu packages golang), is to have the variant package defined
alongside the parent. Here is a patch that should fix this.

Best,
--
Josselin Poiret
-----BEGIN PGP SIGNATURE-----

iQHEBAEBCAAuFiEEOSSM2EHGPMM23K8vUF5AuRYXGooFAmP/HxsQHGRldkBqcG9p
cmV0Lnh5egAKCRBQXkC5FhcailDkDACWJoUikOH0Sm3TuN2wub9ClDdU2XiewHng
11rSnwrUcwIBYIIove1N/q0v2lThStNYyYbMaeN8Zzv43vhdaOZdvY+AYW0S/3Gs
grtppeOV1+5484KJ9abgAHQvDh11xWQPxgsgWcAouRwuTkaLCWrf8nitBugxA6zc
XT62GivMl+mSn7gBm3ws2npJYBaa1xbbbWWHiQQdMsg+Xc+aGKDmVfjspxSPf/+7
8fBZnl87Lfg7ZwyfdsJa1EX+RWWTXCd9pEnrWh2UcSbFwnSXQy2s+L13XJj+Roej
2qmZi4EZvYhtEUhFc+JMFYkHtjcVSQce0Vqi3lGp8/oCkH6kxTNtyEI/s5oZQVSj
WMn8o2iTwElcuVGbYpUYIe0bydVZZek3AA6WjxF/YLz7hOICn+pTqGJ+fcdxmqxg
bQ8Rahl4ihwdoe4Aonw1/HhCCN0OSmilXh5PClgWkwz7u9pCCFPrfdQWVJhj3P2u
ZLNxLOPX7egZpjv4tja87U+qaqGNGyw=
=YPeR
-----END PGP SIGNATURE-----

J
J
Josselin Poiret wrote on 1 Mar 2023 10:48
[PATCH] gnu: go-github-com-robfig-cron-1.2: Move to (gnu packages golang)
527a9cf91049a6aa0ae3ad1c743fafa67faf6e7e.1677664115.git.dev@jpoiret.xyz
Becaus (gnu packages golang) and (gnu packages check) use each other, this
avoids an undefined symbol.

* gnu/packages/check.scm (go-github-com-robfig-cron-1.2): Move to...
* gnu/packages/golang.scm (go-github-com-robfig-cron-1.2): ...here.
---
gnu/packages/check.scm | 18 ------------------
gnu/packages/golang.scm | 18 ++++++++++++++++++
2 files changed, 18 insertions(+), 18 deletions(-)

Toggle diff (62 lines)
diff --git a/gnu/packages/check.scm b/gnu/packages/check.scm
index 4e907afeb6..44860e3018 100644
--- a/gnu/packages/check.scm
+++ b/gnu/packages/check.scm
@@ -1029,24 +1029,6 @@ (define-public cpputest
but it works for any C/C++ project.")
(license license:bsd-3)))
-;; Required by actionlint. The version of `go-github-com-robfig-cron'
-;; packaged in Guix is newer and changed some error messages, causing
-;; unit tests in actionlint to fail.
-(define-public go-github-com-robfig-cron-1.2
- (package
- (inherit go-github-com-robfig-cron)
- (name "go-github-com-robfig-cron")
- (version "1.2.0")
- (source (origin
- (method git-fetch)
- (uri (git-reference
- (url "https://github.com/robfig/cron")
- (commit (string-append "v" version))))
- (file-name (git-file-name name version))
- (sha256
- (base32
- "0nv31m3940d9kf38lw2zs4hpj435bdi9mmim098rb3n4l07qrvva"))))))
-
(define-public actionlint
(package
(name "actionlint")
diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index 7268b661cf..465e0fd4c7 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -6882,6 +6882,24 @@ (define-public go-github-com-robfig-cron
a cron spec parser and job runner.")
(license license:expat)))
+;; Required by actionlint. The version of `go-github-com-robfig-cron'
+;; packaged in Guix is newer and changed some error messages, causing
+;; unit tests in actionlint to fail.
+(define-public go-github-com-robfig-cron-1.2
+ (package
+ (inherit go-github-com-robfig-cron)
+ (name "go-github-com-robfig-cron")
+ (version "1.2.0")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/robfig/cron")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0nv31m3940d9kf38lw2zs4hpj435bdi9mmim098rb3n4l07qrvva"))))))
+
(define-public go-github-com-shirou-gopsutil
(let ((commit "47ef3260b6bf6ead847e7c8fc4101b33c365e399")
(revision "0"))

base-commit: 307d1b626be86ed21d48d44a131ce8490f370a17
--
2.39.1
S
S
Simon Tournier wrote on 1 Mar 2023 11:40
87lekghhzs.fsf@gmail.com
Hi,

On mer., 01 mars 2023 at 10:48, Josselin Poiret via Bug reports for GNU Guix <bug-guix@gnu.org> wrote:
Toggle quote (1 lines)
> Becaus (gnu packages golang) and (gnu packages check) use each other, this
-^
Typo

s/Becaus/Because I guess

Toggle quote (6 lines)
> avoids an undefined symbol.
>
> * gnu/packages/check.scm (go-github-com-robfig-cron-1.2): Move to...
> * gnu/packages/golang.scm (go-github-com-robfig-cron-1.2): ...here.
> ---

Well, I have not given a look at this though. :-)

Cheers,
simon
W
W
Winter wrote on 1 Mar 2023 18:34
Re: bug#61885: `guix import go` fails outside of pre-inst-env
(name . Josselin Poiret)(address . dev@jpoiret.xyz)(address . 61885@debbugs.gnu.org)
0D82D682-36DD-48D9-8854-FDE42C580C4B@winter.cafe
Hi,

Toggle quote (7 lines)
> This is way worse: (gnu packages golang) cannot be loaded at all!
> This is caused by a cycle, (gnu packages golang) uses (gnu packages
> check) and vice-versa, and go-github-com-robfig-cron is defined in (gnu
> packages golang)! So depending on whether you first use (gnu packages
> check) or (gnu packages golang), go-github-com-robfig-cron will not have
> been defined yet, hence the error.

Great catch, thank you!

I still wonder what about pre-inst-env makes it so the order is different -- it's still the same code importing it, after all.

Also, just for posterity: I ran into a situation where I was only able to reproduce this from within a Guix shell, though that may be some oddities with regards to the shell caching symlinks in PATH(?)

I'll try to look into at least the latter issue, no clue what's up with pre-inst-env, though.

Thanks,
Winter
W
W
Winter wrote on 1 Mar 2023 18:52
(name . Josselin Poiret)(address . dev@jpoiret.xyz)(address . 61885@debbugs.gnu.org)
D601594D-B966-4066-8021-4F0E87E845C4@winter.cafe
Toggle quote (5 lines)
> Using (gnu packages check) then (gnu packages golang) doesn't make the
> error appear. The solution imo, esp. since (gnu packages check) already
> uses (gnu packages golang), is to have the variant package defined
> alongside the parent. Here is a patch that should fix this.

To clarify: I do think this is the best solution, though the oddities I mentioned may warrant further investigation into potentially different issues.

In addition to those, I wonder why `guix build` shows that the cyclic package can't be found, rather than throwing an error as `guix import` does. Maybe it's worth fixing that, if possible, to not cause (worse) confusion?

Thanks,
Winter
J
J
Josselin Poiret wrote on 1 Mar 2023 22:04
(name . Winter)(address . winter@winter.cafe)(address . 61885@debbugs.gnu.org)
87h6v4kwsp.fsf@jpoiret.xyz
Hi again,

Winter <winter@winter.cafe> writes:

Toggle quote (2 lines)
> In addition to those, I wonder why `guix build` shows that the cyclic package can't be found, rather than throwing an error as `guix import` does. Maybe it's worth fixing that, if possible, to not cause (worse) confusion?

This is because you should be trying to build
`go-github-com-robfig-cron@1.2`, not `go-github-com-robfig-cron-1.2`!

`guix build` takes specifications, not Guile variable names.

Best,
--
Josselin Poiret
-----BEGIN PGP SIGNATURE-----

iQHEBAEBCAAuFiEEOSSM2EHGPMM23K8vUF5AuRYXGooFAmP/vhAQHGRldkBqcG9p
cmV0Lnh5egAKCRBQXkC5FhcaitWjC/91H8tuoy1YWF8eqD1cj/KhxMfWuqAPAY+E
GUb4nOpAyaVUfSVFkI/zjynMSLFvN56723yqoUz5jesIjbmWog1DpL8/8lWZUmVl
Oxc6ApTzvli/gobXqElL5TYlrHzQvbpdIzp+QU7SDJn6fbCjvfZSUUTrv3jLHj85
Wi+QY7aP/pVI2Y2iQraNs74OCM7/II9oOuCw7XfwM3h/oD4H3b+QgdP8fOxInO+y
Y+wN6FGb07y1mqsh3k3Uxg4SBDfF0lbcDG8xKnFVFTZOwa7M7j0x0n6/T0OMM5/o
hZ4dS+RibnawifawuHRoWehs54/y1pXmCZj1H35CdC53g3Sgbnq1fGlNjqFyHrlg
I3VJQaG83WiiQOTiQiWRy4uz30m6WwuPJa+TVQM6ULX4rmCVbkYaSZ/SsavDxCrZ
0ehRJTuofJqE6IvycKPndfcwtQmcX4jKsRDoffweiGKE9pR0ycyD2Bg/UOZWBJsg
m2jYj0AYTn6GGbvMWGnTixqibnmEkrw=
=UlD+
-----END PGP SIGNATURE-----

M
M
Maxime Devos wrote on 2 Mar 2023 16:11
Re: bug#61911: error: mate-polkit: unbound variable
(name . Julien Lepiller)(address . julien@lepiller.eu)
27cd1079-8e93-f9b8-42b3-584d7bfbf1e8@telenet.be
Op 02-03-2023 om 15:36 schreef Josselin Poiret:
Toggle quote (32 lines)
> Hi Maxime,
>
> Maxime Devos <maximedevos@telenet.be> writes:
>
>> In unknown file:
>> 3 (primitive-load-path "gnu/packages/xfce" #<procedure 7f?>)
>> In gnu/packages/xfce.scm:
>> 1156:19 2 (_)
>> In ice-9/boot-9.scm:
>> 1685:16 1 (raise-exception _ #:continuable? _)
>> 1685:16 0 (raise-exception _ #:continuable? _)
>>
>> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
>> error: mate-polkit: unbound variable
>
> This is the same kind of issue as [1]: both xfce and mate require each
> other (the second through mate -> freedesktop -> kde-frameworks ->
> kde-plasma -> display-managers -> xfce), and depending on the order in
> which they're loaded, mate-polkit-for-xfce might get defined before
> mate-polkit is. The solution I suggested there was to define the
> variant in the same file as the original package, but here I'm not sure
> if this is the right call.
>
> In general, I'd much rather try to get rid of those pesky module cycles,
> as they cause general headaches for guix pull. I remember Julien
> using (guix modules) to do some analysis at the Guix days, maybe we
> could get some pointers on how to handle this specific situation?
>
> WDYT?
>
> [1] https://issues.guix.gnu.org/61885
> (mid: F29B8BFE-A175-4128-8093-4A810681E235@winter.cafe)
I haven't gone to Guix days so I can't comment on that, but I'd like to
note that there are some simple patches for breaking up lots of package
cycles at https://issues.guix.gnu.org/54539#62 (*). In particular,
#:use-module -> #:autoload appears promising (^).
Basically, you can consider a module reference to be 'strong' if its of
the form (define stuff (package (inherit reference)) ...), and 'weak' if
its just a package input (or more generally, something thunked).
'Strong' cycles are problematic, but 'weak' cycles should be resolvable
by delaying loading the required modules until needed.
I don't know if these patches would solve this particular 'mate-polkit'
issue -- if the 'mate -> freedesktop -> ... -> xfce' cycle is 'weak',
something like those patches should work, but if it isn't, those patches
would be insufficient.
(*) Beware of https://issues.guix.gnu.org/54539#63though; looks like I
made some mistakes in hurd.scm and image.scm.
Greetings,
Maxime.
Attachment: OpenPGP_signature
T
T
Tobias Geerinckx-Rice wrote on 2 Mar 2023 23:31
Re: bug#61885: [PATCH] gnu: go-github-com-robfig-cron-1.2: Move to (gnu packages golang)
(address . winter@winter.cafe)(address . 61885-done@debbugs.gnu.org)
87356mu6ik.fsf@nckx
Hi Winter,

Simon Tournier ???
Toggle quote (7 lines)
>> Becaus (gnu packages golang) and (gnu packages check) use each
>> other, this
> -^
> Typo
>
> s/Becaus/Because I guess

Pushed as 997b93cc4a6deff54ebd854a716cca94095114bf with this fix.
Thanks!

I'll close this bug now; the more general problem (and more
work-arounds to it) are tracked in others.

Kind regards,

T G-R
-----BEGIN PGP SIGNATURE-----

iIMEARYKACsWIQT12iAyS4c9C3o4dnINsP+IT1VteQUCZAEkgw0cbWVAdG9iaWFz
LmdyAAoJEA2w/4hPVW15PNwBAPyuoekbDKnFns+2kAGcs2DL0k9Su89202ttRnK8
+ShrAP9UmivhV7Dtu2DZFcmKnwNjJPbDZhrrTilCYjOsb4DlBw==
=AHnB
-----END PGP SIGNATURE-----

Closed
?