https://pantsbuild.org/ logo
#development
Title
# development
n

narrow-vegetable-37489

10/26/2022, 9:26 PM
Seeing some issues with
buf
during
./pants fmt
when manually bumping
buf
to
1.9.0
-> 🧵
Copy code
Failure: exec: "diff": cannot run executable found relative to current directory
The buf backend uses
BinaryShims
to get
diff
into the sandbox when running
buf
. I did some digging around and it sounds like Go since 1.19 (which I assume the latest
buf
release from a few days ago is compiled with) dislikes relative paths in `PATH` when running executables. Taking a look at
BinaryShims.bin_directory
, which is what’s added to
PATH
in order for
buf
to find our sandboxed
diff
, it is very much relative. The easy fix would be to set the absolute path of
BinaryShims.bin_directory
in
PATH
instead. The question is should this path be “absolutified” in the
buf
backend before passing it to
PATH
, or should
BinaryShims
be updated so
bin_directory
always is absolute? I’m also wondering if making it absolute will conflict with Pants’ caching somehow? That’s currently way outside my area of Pants knowledge!
👀 2
h

hundreds-father-404

10/26/2022, 9:28 PM
cc @curved-television-6568 who is the genius behind
BinaryShims
(that is not at all sarcastic, it's a great idea!)
❤️ 1
c

curved-television-6568

10/26/2022, 9:31 PM
darn sanity checks 😛
but yea, making the PATH absolute to the sandbox would likely be a good idea, but one we don’t know when constructing PATH unfortunately, so would have to be a bootstrap step to adjust path before proceeding, I think
Jonas, if you wouldn’t mind opening a ticket on GH so can we track it there thanks 🙂
n

narrow-vegetable-37489

10/26/2022, 9:34 PM
Will do! I just tried patching
__run.sh
in the sandbox manually with an absolute
PATH
instead and that made
buf
very happy.
f

fast-nail-55400

10/26/2022, 9:43 PM
we already have some examples of patching in sandbox absolute path for the GoSdkProcess rule
so would have to be a bootstrap step to adjust path before proceeding, I think
yup!
n

narrow-vegetable-37489

10/26/2022, 9:48 PM
Thanks everyone! Created an issue: https://github.com/pantsbuild/pants/issues/17363
👍 1
c

curved-television-6568

10/27/2022, 3:10 AM
As it turns out, I’d forgotten we already had faced and solved this issue before (now I do recall it was a go binary that time as well) here: https://github.com/pantsbuild/pants/blob/75277a040c14c72d7365b51b06e59954a1651e96/src/python/pants/backend/docker/util_rules/docker_binary.py#L157
What is a little unfortunate is that it’s up to each call site to append the chroot prefix thing… maybe it could be a flag on the binary shims request whether the response has it on it’s path or not… as most times, it’ll likely be used as a PATH entry in which case it makes sense to have it.
Ah, hmm.. and as @fast-nail-55400 has pointed out in that PR is that this doesn’t work for remote execution, we’ll have to think of a better approach to solve this for the general case.
f

fast-nail-55400

10/27/2022, 4:21 PM
I should have a solution for remote execution soon. I’m adding a wrapper script there to support append-only caches; easy enough to extend that wrapper to support substituting a path.
🙌 1