purple-plastic-57801
05/16/2023, 12:38 AMsystem_binary(
name="git",
binary_name="git",
)
Leads to
pants run .build:build-libcamera
17:37:36.50 [INFO] Completed: Testing candidate for `git` at `/bin/git`
17:37:36.50 [INFO] Completed: Testing candidate for `git` at `/usr/bin/git`
17:37:36.51 [ERROR] 1 Exception encountered:
Engine traceback:
in `run` goal
ValueError: Could not find a binary with name `git`. The following paths were searched: /usr/bin, /bin, /usr/local/bin, /opt/homebrew/bin.
But..
which git
/usr/bin/git
enough-analyst-54434
05/16/2023, 12:51 AM--keep-sandboxes=always
and see for yourself what "Testing candidate for git
at `/usr/bin/git`" sees,purple-plastic-57801
05/16/2023, 12:53 AMpants run .build:libcamera --keep-sandboxes=always
17:52:03.84 [INFO] Initialization options changed: reinitializing scheduler...
17:52:08.36 [INFO] Scheduler initialized.
17:52:08.47 [INFO] Preserving local process execution dir /tmp/pants-sandbox-5nreNe for Searching for `bash` on PATH=/usr/bin:/bin:/usr/local/bin
17:52:08.51 [INFO] Preserving local process execution dir /tmp/pants-sandbox-gSV1Op for Test binary /usr/bin/bash.
17:52:08.51 [INFO] Preserving local process execution dir /tmp/pants-sandbox-KntnE3 for Test binary /bin/bash.
17:52:08.57 [INFO] Preserving local process execution dir /tmp/pants-sandbox-Ee4YW5 for Searching for `git` on PATH=/usr/bin:/bin:/usr/local/bin:/opt/homebrew/bin
17:52:08.61 [INFO] Preserving local process execution dir /tmp/pants-sandbox-Ce8jj4 for Testing candidate for `git` at `/bin/git`
17:52:08.61 [INFO] Preserving local process execution dir /tmp/pants-sandbox-usMJKB for Testing candidate for `git` at `/usr/bin/git`
17:52:08.80 [INFO] Completed: Testing candidate for `git` at `/bin/git`
17:52:08.80 [INFO] Completed: Testing candidate for `git` at `/usr/bin/git`
17:52:08.82 [ERROR] 1 Exception encountered:
Engine traceback:
in `run` goal
ValueError: Could not find a binary with name `git`. The following paths were searched: /usr/bin, /usr/bin, /bin, /usr/local/bin, /opt/homebrew/bin.
enough-analyst-54434
05/16/2023, 12:53 AMPreserving local process execution dir /tmp/pants-sandbox-usMJKB for Testing candidate for `git` at `/usr/bin/git`
So cd to /tmp/pants-sandbox-usMJKB
__run.sh
script that encodes what Pants tried.purple-plastic-57801
05/16/2023, 12:55 AMenough-analyst-54434
05/16/2023, 12:56 AMgit
presumably git --version
or something?purple-plastic-57801
05/16/2023, 12:56 AMsystem_binary(
name="git",
binary_name="git",
)
enough-analyst-54434
05/16/2023, 12:56 AMpurple-plastic-57801
05/16/2023, 12:56 AMenough-analyst-54434
05/16/2023, 12:56 AMpurple-plastic-57801
05/16/2023, 12:57 AMenough-analyst-54434
05/16/2023, 12:57 AM__run.sh
exactly?purple-plastic-57801
05/16/2023, 12:57 AMcat __run.sh
#!/bin/bash
# This command line should execute the same process as pants did internally.
export
cd /tmp/pants-sandbox-usMJKB
/usr/bin/git
enough-analyst-54434
05/16/2023, 12:58 AMpurple-plastic-57801
05/16/2023, 1:01 AMenough-analyst-54434
05/16/2023, 1:03 AMbroad-processor-92400
05/16/2023, 2:52 AMpurple-plastic-57801
05/17/2023, 12:54 AMsystem_binary(
name="npm",
binary_name="npm",
fingerprint=r"9.2.0",
fingerprint_args=["--version"],
)
cat /tmp/pants-sandbox-MjbXO2/__run.sh
#!/bin/bash
# This command line should execute the same process as pants did internally.
export
cd /tmp/pants-sandbox-MjbXO2
/usr/bin/npm --version
pants run teletom/frontend:npm --keep-sandboxes=always
17:52:33.49 [INFO] Preserving local process execution dir /tmp/pants-sandbox-ewKBkO for Testing candidate for `npm` at `/bin/npm`
17:52:33.49 [INFO] Preserving local process execution dir /tmp/pants-sandbox-MjbXO2 for Testing candidate for `npm` at `/usr/bin/npm`
17:52:33.55 [INFO] Completed: Testing candidate for `npm` at `/bin/npm`
17:52:33.55 [INFO] Completed: Testing candidate for `npm` at `/usr/bin/npm`
17:52:33.55 [ERROR] 1 Exception encountered:
Engine traceback:
in `run` goal
ValueError: Could not find a binary with name `npm` with output matching `9.2.0` when run with arguments `--version`. The following paths were searched: /usr/bin, /bin, /usr/local/bin, /opt/homebrew/bin.
bash /tmp/pants-sandbox-MjbXO2/__run.sh | tail
declare -x XDG_RUNTIME_DIR="/run/user/1000"
declare -x XDG_SEAT="seat0"
declare -x XDG_SESSION_CLASS="user"
declare -x XDG_SESSION_DESKTOP="i3"
declare -x XDG_SESSION_ID="3"
declare -x XDG_SESSION_TYPE="x11"
declare -x XDG_VTNR="2"
declare -x XMODIFIERS="@im=ibus"
declare -x _="/usr/bin/bash"
9.2.0
echo $?
0
enough-analyst-54434
05/17/2023, 1:10 AMpurple-plastic-57801
05/17/2023, 1:11 AMenough-analyst-54434
05/17/2023, 1:11 AMpurple-plastic-57801
05/17/2023, 1:13 AMenough-analyst-54434
05/17/2023, 1:14 AMfingerprint_args=["--version\n"],
?purple-plastic-57801
05/17/2023, 1:15 AMenough-analyst-54434
05/17/2023, 1:15 AMfingerprint=r"9.2.0\n"
broad-processor-92400
05/17/2023, 1:15 AMfingerprint
is matched with re.match
, i.e. needs to be at the start.
2. in 2.16 __run.sh
isn't fully hermetic and leaks env vars from your shell, so the behaviour inside pants may be different to running it outside
I think 2 might be the problem here: npm
needs node
available to run, and so the fingerprint_dependencies=[...]
field will need to include a node
system_binary
export
being empty, I think switching the last line in __run.sh
to env -i /usr/bin/npm --version
will properly reproduce the in-pants behaviourpurple-plastic-57801
05/17/2023, 1:17 AMsystem_binary(
name="npm",
binary_name="npm",
fingerprint=r"9.2.0",
fingerprint_args=["--version"],
fingerprint_dependencies=[":node"],
)