https://pantsbuild.org/ logo
a

abundant-hospital-56388

06/21/2022, 3:07 PM
Is there a way that I can execute a command that I run with
./pants run
as
sudo
without pants switching to the root user cache?
s

square-forest-55300

06/21/2022, 3:14 PM
first of all: sounds like a bad idea to do this.
i would probably create a group/role with the specific rights necessary
i guess it highly depends on what you're trying to do
h

happy-kitchen-89482

06/21/2022, 3:30 PM
You can re-set the paths to the caches back to those under the non-su's homedir with these options (via cmd-line flag or env var, or supplemental config file): ā€¢ https://www.pantsbuild.org/docs/reference-global#section-local-store-dir ā€¢ https://www.pantsbuild.org/docs/reference-global#section-named-caches-dir
šŸ™‚ 1
I think the
./pants
script also uses the homedir for something, you might have to tweak that as well
But keep in mind that Pants will write files as the root user, and this may mess with any future runs as the non-root user
This overall seems like it will be trouble
šŸ’Æ 1
s

square-forest-55300

06/21/2022, 3:34 PM
not only for build artifacts and executables. You got pants (service) running as a root then.
a

abundant-hospital-56388

06/21/2022, 3:35 PM
Thanks guys for the suggestions and infos. You're absolutely right about not doing that. I'll look into how I can restructure the process there to not require sudo at that place.
šŸ‘ 1
s

square-forest-55300

06/21/2022, 3:40 PM
I don't think this is something, you would want to do, ever. I'm even splitting building and installing software with Make. It does mess with git repositories from time to time as well
Regardless of which build system you are using