On Sunday, September 22nd, 2024 at 1:34 AM, Konrad Hinsen
<konrad.hin...@fastmail.net> wrote:
>
>
> Hi Simon,
>
> > > Unfortunately, when there are several packages with identical name and
> > > version number in two channels, Guix silently chooses one of them.
> >
> > Choose when doing what? :-)
>
>
> Building, installing, ... whatever you can do with a package.
>
> > When running “guix shell” or “guix package”, it should warn. It
> > doesn’t? Ah? I thought it does… Hum?
>
>
> It doesn't.
Whether it does or doesn't depends on the versions of the duplicate packages in
question. If both packages have the same version, then the command line tools
will warn about the ambiguous package specification. If the version numbers are
different, then the tools will quietly choose the "newer" version (the larger
version number).
For example, I have a local channel that included an updated version of yt-dlp,
and the version in Guix has since been updated to the same version:
$ guix package -A yt-dlp
yt-dlp 2024.08.06 out local/packages/updated.scm:157:2
yt-dlp 2024.08.06 out gnu/packages/video.scm:3163:2
$ guix build yt-dlp
guix build: warning: ambiguous package specification `yt-dlp'
guix build: warning: choosing yt-dlp@2024.08.06 from
gnu/packages/video.scm:3163:2
But if I change the local version to be different (say the fictitious
"2024.09.06"), I no longer get a warning:
$ guix build -L ~/guix/local yt-dlp
substitute: updating substitutes from...
>
> > When packaging, you choose: you use one module or the other, or both.
>
>
> Right, at the level of Guile code, there is no problem. It's the lookup
> by name/version at the command line that doesn't let me choose nor tells
> me that there is a need to choose.
Assuming the packages with the same name have different versions, you'd need to
specify at least part of the version on the command line to get the older
version. In Guix, both GTK+ 2/3 and QT 5/6 are examples where that is needed:
$ guix package -A qtbase
qtbase 6.6.3 out,debug gnu/packages/qt.scm:716:2
qtbase 5.15.10 out,debug gnu/packages/qt.scm:450:2
$ guix build -n --no-substitutes qtbase
The following derivations would be built:
/gnu/store/49vfjglgi4myb4c2sa59gjypa3sr05il-qtbase-6.6.3.drv
$ guix build -n --no-substitutes qtbase@5
The following derivations would be built:
/gnu/store/9bpsq64ljwx2yf1gvw9kby2wda0bcx6a-qtbase-5.15.10.drv
However, if there are two packages with the same name and version, then to
select a specific one you'd have to use the "-e" flag with a Scheme expression
that evaluates to the desired package. Using the previous yt-dlp example, to
specify the one in my local channel instead of the one from the guix channel
that it warned it was choosing, I'd run:
guix build -e '(@ (local packages updated) yt-dlp)'
The reason using an expression is needed is because the package specifications
like "yt-dlp" or "qtbase@5" are not expressive enough to handle a distinction
when the full package name and version--like "yt-dlp@2024.08.06"--match more
than one package definition.
This also raises a question that I don't think has been asked yet: is the local
package you are modifying the same version as the package of the same name in
the guix channel?
HTH!
Cheers,
Kaelyn