How can I get the caller's CWD in rule code? Norma...
# development
b
How can I get the caller's CWD in rule code? Normally we assume project root, but I wanna handle
../../pants arg1 arg2
h
I don't think we have any current way to do this. And you have to be careful with memoization with the daemon that running
../../pants
and then
./pants
right after needs to invalidate the value
b
Right now I'm assuming it is build root, which is likely true most of the time? But still I hate the assumption
h
Yeah, Pants only works from build root. Which is a huge UX issue. You should be able to run Pants from any directory
c
In https://github.com/kaos/pants-shim/blob/main/src/pants.sh I’ve played with an idea to have a “pants” shim that you can invoke from where ever and it should pick up your build root for you and
cd
to it before actually invoking pants. but I guess a better more robust thing would be to have pants detect the build root itself and not touch CWD..
b
Actually for my work (https://github.com/pantsbuild/pants/issues/17540) even CWD is likely wrong. So Build Root is the best we got until https://github.com/microsoft/debugpy/issues/1130 is fixed
w
It's
BuildRoot
currently, always
b
I actually figured out how to fix my issue CWD/build_root agnostic 🙂