user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <>
To: Alyssa Ross <>
Subject: Re: [PATCH] t/spawn: fix with unusual env locations
Date: Sun, 15 Sep 2019 18:55:19 +0000	[thread overview]
Message-ID: <20190915185519.GA4891@dcvr> (raw)
In-Reply-To: <>

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/ b/lib/PublicInbox/
index 25c8c87f..29b13371 100644
--- a/lib/PublicInbox/
+++ b/lib/PublicInbox/
@@ -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.

  reply	other threads:[~2019-09-15 18:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-15 13:48 [PATCH] t/spawn: fix with unusual env locations Alyssa Ross
2019-09-15 18:55 ` Eric Wong [this message]
2019-09-24  1:11   ` Alyssa Ross
2019-09-24  4:01     ` Eric Wong
2019-09-24 22:12       ` Test failures in build sandbox Alyssa Ross
2019-09-26  8:44         ` Eric Wong
2019-10-02 23:23           ` Alyssa Ross
2019-10-03  0:46             ` Alyssa Ross
2019-10-03  1:28               ` Eric Wong
2019-10-03  1:43                 ` Alyssa Ross
2019-10-03  7:57                   ` [PATCH] t/search: bail out on `git init --shared' failures Eric Wong
2019-10-03 10:15                     ` Alyssa Ross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190915185519.GA4891@dcvr \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).