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

From: [email-masked] (Ludovic Courtès)
Date: Wed, 17 Oct 2018 14:19:33 +0200

Hello Mike,

There’s this last patch from the series you submitted a while back
that’s ready modulo an issue with the test.  Could you take a look?

TIA,
Ludo’.

[email-masked] (Ludovic Courtès) skribis:

> Mike Gerwitz <[email-masked]> skribis:
>
>> * doc/guix.texi (Invoking guix environment): Add --no-cwd.
>> * guix/scripts/environment.scm (show-help, %options): Add --no-cwd.
>> (launch-environment/container): Add 'map-cwd?' param; only add mapping for cwd
>> if #t.  Only change to cwd within container if #t, otherwise home.
>> (guix-environment): Error if --no-cwd without --container.  Provide '(not
>> no-cwd?)' to launch-environment/container as 'map-cwd?'.
>> * tests/guix-environment.sh: Add test for no-cwd.
>
> This one LGTM as well (with the test moved to
> guix-environment-container.sh).  There’s just a minor issue:
>
>> --- 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?
>
> TIA,
> Ludo’.