Subject: bug#57932: `environment_variables` in build containers are set wrong

From: Ekaitz Zarraga <[email-masked]>
Date: Mon, 19 Sep 2022 11:17:15 +0000

Hi,

I have a package that depends on `mes`.

When I build it with `guix build $package -K` and I jump to the resulting build directory, the `environment_variables` file looks like this:

```
export LIBRARY_PATH="/gnu/store/hy6abswwv4d89zp464fw52z65fkzr7h5-perl-5.34.0/lib:/gnu/store/22n2s0vfvqg9v0as9h7fpdn1i9dmryvi-texinfo-6.7/lib:/gnu/store/kijj8bhcaz984jbgbshrdabzd07cg1zv-mes-0.24/lib:/gnu/store/s3hl12jxz9ybs7nsy7kq7ybzz7qnzmsg-bzip2-1.0.8/lib:/gnu/store/c8isj4jq6knv0icfgr43di6q3nvdzkx7-xz-5.2.5/lib:/gnu/store/4ic6244i3ca4b4rxc2wnrgllsidyishv-file-5.39/lib:/gnu/store/690qz3fg334dpwn3pn6k59n4wc943p2b-gawk-5.1.0/lib:/gnu/store/rc781v4k0drhaqn90xfwwpspki5x0bvf-binutils-2.37/lib:/gnu/store/5h2w4qi9hk1qzzgi1w83220ydslinr4s-glibc-2.33/lib:/gnu/store/4jdghmc65q7i7ib89zmvq66l0ghf7jc4-glibc-2.33-static/lib:/gnu/store/fnr1z6xsan0437r0yg48d0y8k32kqxby-glibc-utf8-locales-2.33/lib:/gnu/store/9xn2y515vv9p0vgww4add3lphwi17q07-nyacc-1.00.2/lib"
export MES_PREFIX="/gnu/store/hy6abswwv4d89zp464fw52z65fkzr7h5-perl-5.34.0/"
```

The `MES_PREFIX` is set to Perl's installation directory, which is also the first element in `LIBRARY_PATH`.

If I change the order of the package inputs the order of the `LIBRARY_PATH` changes, which is not important, but the first element of `LIBRARY_PATH` is always the one in the `MES_PREFIX`. This doesn't look like the proper behavior: it should always be /gnu/store/*-mes-*

Best,
Ekaitz