diff mbox series

[bug#42735] pre-inst-env: don't use GUIX_PACKAGE_PATH

Message ID 20200807022142.26296-1-GNUtoo@cyberdimension.org
State Accepted
Headers show
Series [bug#42735] pre-inst-env: don't use GUIX_PACKAGE_PATH | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job

Commit Message

Denis 'GNUtoo' Carikli Aug. 7, 2020, 2:21 a.m. UTC
./pre-inst-env is supposed to use only the packages definitions that are in
the guix source tree and not the host packages.

However if GUIX_PACKAGE_PATH is set, it will use host packages as well.

In addition, when packages are defined in both the guix source tree and in
GUIX_PACKAGE_PATH, GUIX_PACKAGE_PATH will take the precedence and guix
will print warnings like that:
    guix build: warning: ambiguous package specification `libsamsung-ipc'
    guix build: warning: choosing libsamsung-ipc@0.1 from
                         /home/[...]/.config/guix/local/replicant.scm:31:2

That situation can happen when working in a new package in
GUIX_PACKAGE_PATH and then importing the package in the guix source tree to
add it upstream.

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
---
 build-aux/pre-inst-env.in | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Brett Gilio Aug. 7, 2020, 3:46 a.m. UTC | #1
Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> writes:

>  
> +# Make sure we don't use local package definitions
> +GUIX_PACKAGE_PATH=""
> +export GUIX_PACKAGE_PATH
> +
>  exec "$@"

Wouldn't it make more sense to use `unset` instead of defining an empty
variable?
Denis 'GNUtoo' Carikli Aug. 7, 2020, 6:02 a.m. UTC | #2
On Thu, 06 Aug 2020 22:46:52 -0500
Brett Gilio <brettg@gnu.org> wrote:

> Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> writes:
> 
> >  
> > +# Make sure we don't use local package definitions
> > +GUIX_PACKAGE_PATH=""
> > +export GUIX_PACKAGE_PATH
> > +
> >  exec "$@"
> 
> Wouldn't it make more sense to use `unset` instead of defining an
> empty variable?
I used export and defined an empty variable because I don't know how to
write portable shell scripts and export was already used in
build-aux/pre-inst-env.in.

Is unset portable? If so should I resend a patch with unset instead?

Denis.
Mathieu Othacehe Aug. 7, 2020, 8:41 a.m. UTC | #3
Hello Denis,

> ./pre-inst-env is supposed to use only the packages definitions that are in
> the guix source tree and not the host packages.
>
> However if GUIX_PACKAGE_PATH is set, it will use host packages as well.

Let say you have a custom my-hello package inheriting from hello, and
you want to build it on top of a recent Guix checkout, then you probably
want GUIX_PACKAGE_PATH to cooperate with pre-inst-env.

Same goes if you have a manifest mixing Guix packages and custom
packages accessed by GUIX_PACKAGE_PATH, and you want to test your
manifest on top of a Guix checkout using pre-inst-env.

Thanks,

Mathieu
Denis 'GNUtoo' Carikli Aug. 9, 2020, 9:09 a.m. UTC | #4
On Fri, 07 Aug 2020 10:41:52 +0200
Mathieu Othacehe <othacehe@gnu.org> wrote:
> Let say you have a custom my-hello package inheriting from hello, and
> you want to build it on top of a recent Guix checkout, then you
> probably want GUIX_PACKAGE_PATH to cooperate with pre-inst-env.
> 
> Same goes if you have a manifest mixing Guix packages and custom
> packages accessed by GUIX_PACKAGE_PATH, and you want to test your
> manifest on top of a Guix checkout using pre-inst-env.
Thanks for the explanation.

What would be the way for both use cases to be addressed?

Should a warning be emitted when packages come from GUIX_PACKAGE_PATH
with ./pre-inst-env ?

What about something that would look like that:
>    guix build: warning: GUIX_PACKAGE_PATH is set
>    guix build: warning: choosing my-hello@0.1 from
>                         /home/[...]/.config/guix/local/custom.scm:31:2
>    guix build: warning: If you don't want to use
>                         packages from GUIX_PACKAGE_PATH you can run
>                         'unset GUIX_PACKAGE_PATH' before running
>                         pre-inst-env

The issue is if it picks dependencies from GUIX_PACKAGE_PATH which are
not in Guix source code yet. In that case it might be more complicated
to make sure that people will see the warning as it might be hidden in
the huge build log.

Another option which can also be combined with the previous one would be
to warn people in the manual.

Note that I'm also fine with the status quo, but if it's not too
complicated to improve the situation in a way that doesn't break
existing use cases it would probably make sense to do it.

Denis.
Oleg Pykhalov Aug. 14, 2020, 10 a.m. UTC | #5
Hi,

Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> writes:

[…]

> Should a warning be emitted when packages come from GUIX_PACKAGE_PATH
> with ./pre-inst-env ?

I don't think a user needs another warning for an environment variable
which he setted by himself.  Also, user could use ‘-L’ flag instead of
‘GUIX_PACKAGE_PATH’.


Currently,

with ‘hello’ package in GUIX_PACKAGE_PATH:
--8<---------------cut here---------------start------------->8---
oleg@guixsd ~/src/guix-master$ GUIX_PACKAGE_PATH=/home/oleg/src/guix-wigust/guix ./pre-inst-env guix build --no-grafts --no-offload hello
guix build: warning: ambiguous package specification `hello'
guix build: warning: choosing hello@2.10 from /home/oleg/src/guix-wigust/guix/wigust/packages/games.scm:174:2
/gnu/store/a462kby1q51ndvxdv3b6p0rsixxrgx1h-hello-2.10
--8<---------------cut here---------------end--------------->8---

without ‘hello’ package in GUIX_PACKAGE_PATH:
--8<---------------cut here---------------start------------->8---
oleg@guixsd ~/src/guix-master$ GUIX_PACKAGE_PATH=/home/oleg/src/guix-wigust/guix ./pre-inst-env guix build --no-grafts --no-offload hello
/gnu/store/a462kby1q51ndvxdv3b6p0rsixxrgx1h-hello-2.10
--8<---------------cut here---------------end--------------->8---

> The issue is if it picks dependencies from GUIX_PACKAGE_PATH which are
> not in Guix source code yet. In that case it might be more complicated
> to make sure that people will see the warning as it might be hidden in
> the huge build log.
>
> Another option which can also be combined with the previous one would be
> to warn people in the manual.

It's already documented, isn't it?

https://www.gnu.org/software/guix/manual/html_node/Package-Modules.html
--8<---------------cut here---------------start------------->8---
 -- Environment Variable: GUIX_PACKAGE_PATH
     This is a colon-separated list of directories to search for
     additional package modules.  Directories listed in this variable
     take precedence over the own modules of the distribution.
--8<---------------cut here---------------end--------------->8---

I'll close the bug.  Feel free to reopen if I miss something.


Regards,
Oleg.
Ricardo Wurmus Aug. 14, 2020, 11:16 a.m. UTC | #6
Mathieu Othacehe <othacehe@gnu.org> writes:

> Hello Denis,
>
>> ./pre-inst-env is supposed to use only the packages definitions that are in
>> the guix source tree and not the host packages.
>>
>> However if GUIX_PACKAGE_PATH is set, it will use host packages as well.
>
> Let say you have a custom my-hello package inheriting from hello, and
> you want to build it on top of a recent Guix checkout, then you probably
> want GUIX_PACKAGE_PATH to cooperate with pre-inst-env.

That’s primarily how I use GUIX_PACKAGE_PATH: for development.  If you
have GUIX_PACKAGE_PATH set for any other reasons you should consider
using channels instead.
diff mbox series

Patch

diff --git a/build-aux/pre-inst-env.in b/build-aux/pre-inst-env.in
index e0aa7fe868..698a7994fb 100644
--- a/build-aux/pre-inst-env.in
+++ b/build-aux/pre-inst-env.in
@@ -59,4 +59,8 @@  export NIX_HASH
 GUIX_UNINSTALLED=1
 export GUIX_UNINSTALLED
 
+# Make sure we don't use local package definitions
+GUIX_PACKAGE_PATH=""
+export GUIX_PACKAGE_PATH
+
 exec "$@"