Subject: bug#46782: closed (Re: bug#46782: guix environment --expose options cannot be layered onto $PWD)

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 07 Mar 2023 02:24:02 +0000

Your bug report

#46782: guix environment --expose options cannot be layered onto $PWD

which was filed against the guix package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
46782: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=46782
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#46782: guix environment --expose options cannot be layered onto $PWD
From: Maxim Cournoyer <[email-masked]>
To: Josselin Poiret <[email-masked]>
Cc: [email-masked], [email-masked], bbb ee <[email-masked]>, Simon Tournier <[email-masked]>
Date: Mon, 06 Mar 2023 21:23:24 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello Josselin,

Josselin Poiret <[email-masked]> writes:

> Hello everyone,
>
> A quick strace shows that it's actually an ordering issue: /home/user is
> mounted in the container after /home/user/tmp.  The fix is pretty
> simple, moving the cwd first, before the explicit --expose arguments.

Thanks for the troubleshooting and patch!  I've now applied it.

> I'm noticing that the --expose option creates an empty tmp folder in the
> user's home in that case though, which I don't like, however I don't
> think there's any better option.  Patch following.

At least it's better to be left with an empty directory than with
mysteriously nothing happening and the use case not working as expected
:-).

-- 
Thanks,
Maxim

Subject: guix environment --expose options cannot be layered onto $PWD
From: Maxim Cournoyer <[email-masked]>
To: bug-guix <[email-masked]>
Date: Thu, 25 Feb 2021 16:12:34 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello Guix!

I noticed, while trying to expose the SSL environment variable inside a
container and doing things such as:

--8<---------------cut here---------------start------------->8---
guix environment --container --network -E SSL --expose=$SSL_CERT_FILE \
     --expose=$SSL_CERT_DIR --ad-hoc [...]
--8<---------------cut here---------------end--------------->8---

that it wasn't possible to expose things onto the implicitly mounted
current working directory.  No error message would be shown, yet the
--expose arguments wouldn't go through unless using --no-cwd.

Here's a minimal example:

--8<---------------cut here---------------start------------->8---
$ guix environment -C --expose=/tmp=$PWD/tmp \
  --ad-hoc bash coreutils -- bash -c 'stat $PWD/tmp'
stat: cannot statx '/var/lib/jenkins/tmp': No such file or directory
--8<---------------cut here---------------end--------------->8---

but,

--8<---------------cut here---------------start------------->8---
$ guix environment --no-cwd -C --expose=/tmp=$PWD/tmp \
  --ad-hoc bash coreutils -- bash -c 'stat $PWD/tmp'
  File: /var/lib/jenkins/tmp
  Size: 73728           Blocks: 152        IO Block: 4096   directory
Device: fd00h/64768d    Inode: 1966081     Links: 397
Access: (1777/drwxrwxrwt)  Uid: (65534/ UNKNOWN)   Gid: (65534/overflow)
Access: 2021-02-25 20:40:08.534757708 +0000
Modify: 2021-02-25 21:10:49.205636074 +0000
Change: 2021-02-25 21:10:49.205636074 +0000
 Birth: 2016-12-07 20:43:16.029221570 +0000
--8<---------------cut here---------------end--------------->8---

succeeds.

I can't think of a technical reason why layering bind mounts wouldn't
work; in fact it already appear to work for multiple --expose options
touching the same hierarchy of files.

If there's a technical reason this cannot/shouldn't happen, we should
warn the user about it.

Thanks,

Maxim