Subject: [bug#30256] [PATCH 3/3] scripts: environment: Add --no-cwd.

From: Mike Gerwitz <[email-masked]>
Date: Fri, 02 Mar 2018 13:00:36 -0500

Hey, Ludo!

Sorry I've been silent on the script you provided to me---between my GNU
volunteer work and preparing for my LP2018 talk, I've had no free time,
so I haven't even looked at it yet.  After the conference I'll have the
time to collaborate a bit more.

Also---I thought the decision was that this patchset was inappropriate
for `guix environment`; did I misinterpret?

On Fri, Mar 02, 2018 at 11:54:30 +0100, Ludovic Courtès wrote:
>> --- a/tests/guix-environment.sh
>> +++ b/tests/guix-environment.sh
>> @@ -84,6 +84,14 @@ HOME="$tmpdir" guix environment --bootstrap --container --user=foognu \
>>       --share="$tmpdir/umock" \
>>       -- guile -c "$usertest"
>>  
>> +# if not sharing CWD, chdir home
>> +(
>> +  cd "$tmpdir" \
>> +    && guix environment --bootstrap --container --no-cwd --user=foo  \
>> +            --ad-hoc guile-bootstrap --pure \
>> +            -- /bin/sh -c 'test $(pwd) == "/home/foo" -a ! -d '"$tmpdir"
>> +)
>> +
>
> This test would fail for me because my test store is at
> ~ludo/src/guix/test-tmp/store and my CWD is ~/src/guix.  So when using
> both --user and --no-cwd, the effect is that
> ~ludo/src/guix/test-tmp/store is not available at all within the
> container, and thus execve("/bin/sh") fails with ENOENT:
>
> $ ./test-env guix environment --bootstrap --container --no-cwd --user=foo --ad-hoc guile-bootstrap
> accepted connection from pid 29684, user ludo
> accepted connection from pid 29695, user ludo
> ./test-env: line 1: 29683 Terminated              "/home/ludo/src/guix/pre-inst-env" "/home/ludo/src/guix/guix-daemon" --disable-chroot --substitute-urls="$GUIX_BINARY_SUBSTITUTE_URL"
> $ echo $?
> 1
>
> Thoughts?

I admit that I forgot some of the implementation details of my own
patch; I'd have to look at it in more detail.  I'll consider it tonight
or this weekend.

Thanks for taking a look at and applying these.  If there are better
solutions, I'm fine with that---I just wanted a proof-of-concept to
start the discussion.  Though, starting the discussion and then ducking
out for other obligations wasn't quite what I had in mind...

-- 
Mike Gerwitz
Free Software Hacker+Activist | GNU Maintainer & Volunteer
GPG: D6E9 B930 028A 6C38 F43B  2388 FEF6 3574 5E6F 6D05
https://mikegerwitz.com