From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 7AAB61F463; Sun, 15 Sep 2019 18:55:19 +0000 (UTC) Date: Sun, 15 Sep 2019 18:55:19 +0000 From: Eric Wong To: Alyssa Ross Cc: meta@public-inbox.org Subject: Re: [PATCH] t/spawn: fix with unusual env locations Message-ID: <20190915185519.GA4891@dcvr> References: <20190915134819.1406-1-hi@alyssa.is> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190915134819.1406-1-hi@alyssa.is> List-Id: Alyssa Ross wrote: > The call to spawn clears the environment, including PATH. This means > that an env in a non-default location wouldn't be found, while all the > other tests work because they use PATH. We can fix this by looking up > which PATH to use beforehand. Thanks for reporting this issue, but... is that it? We also use spawn() for 'git', among other things... > I ran into this when packaging public-inbox for Nixpkgs. We build in > a chroot, and in this case the env I wanted to use was at > /nix/store/7rmjki86923bw1inx0czpp4wgy0kk687-coreutils-8.31/bin/env. The Inline::C version of spawn (enabled by setting PERL_INLINE_DIRECTORY) should already be using the result of which() for every execve(2) call it does. For the pure Perl codepath, this ought to be a more encompassing alternative to your patch: diff --git a/lib/PublicInbox/SpawnPP.pm b/lib/PublicInbox/SpawnPP.pm index 25c8c87f..29b13371 100644 --- a/lib/PublicInbox/SpawnPP.pm +++ b/lib/PublicInbox/SpawnPP.pm @@ -38,11 +38,13 @@ sub pi_fork_exec ($$$$$$) { } if ($ENV{MOD_PERL}) { - exec qw(env -i), @$env, @$cmd; + exec which('env'), '-i', @$env, @$cmd; die "exec env -i ... $cmd->[0] failed: $!\n"; } else { local %ENV = map { split(/=/, $_, 2) } @$env; - exec @$cmd; + my @cmd = @$cmd; + $cmd[0] = $f; + exec @cmd; die "exec $cmd->[0] failed: $!\n"; } } Can you confirm? Thanks.