Seeing some issues with `buf` during `./pants fmt`...
# development
n
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
cc @curved-television-6568 who is the genius behind
BinaryShims
(that is not at all sarcastic, it's a great idea!)
ā¤ļø 1
c
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
Will do! I just tried patching
__run.sh
in the sandbox manually with an absolute
PATH
instead and that made
buf
very happy.
f
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
Thanks everyone! Created an issue: https://github.com/pantsbuild/pants/issues/17363
šŸ‘ 1
c
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
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