fresh-cat-90827
08/20/2021, 3:32 PMchroot.fresh-cat-90827
08/20/2021, 3:32 PMWhen Pants runs most processes, it runs in a chroot (temporary directory). Usually, this gets cleaned up after the Process finishes. You can instead run ./pants --no-process-execution-local-cleanup, which will keep around the folder.The plugin I work on (building a Debian package) is run itself as
chroot (and Pants runs the Process under chroot as well). This causes the dpkg-deb (system utility that builds a Debian package) to fail reading the input files. By running with --no-process-execution-local-cleanup, I can see that the necessary files have been copied and the __run.sh contains correct instructions and can be re-run in that temp directory producing the expected results. However, the ./pants package //:sample-debian-package --no-process-execution-local-cleanup command fails.
stdout:
dpkg-deb: building package 'sample-debian-package' in 'sample-debian-package.deb'.
stderr:
dpkg-deb (subprocess): unable to execute tar -cf (tar): No such file or directory
dpkg-deb: error: tar -cf subprocess returned error exit status 2
I don’t think there was a precedent for this — as far as I know, none of the Pants internal operations (or via plugins) deal with chroot (in the same way that Debian dpkg-deb utility does). I’ve researched on dpkg-deb and how one can configure it with regards to chroot, but haven’t found anything useful.
Is there a way to experiment running a Process not under chroot to see if it is indeed the cause of the trouble so that we could think of a workaround?fast-nail-55400
08/20/2021, 3:38 PMtar need to be available in the chroot setup by Pants? and is it?fast-nail-55400
08/20/2021, 3:39 PMdpkg-deb (subprocess): unable to execute tar -cf (tar): No such file or directory refers to tar being missing.)fresh-cat-90827
08/20/2021, 3:42 PMdoes tar need to be available in the chroot setup by Pants?I wish I knew how to check that 🙂
fresh-cat-90827
08/20/2021, 3:43 PMtar will be used by dpkg-deb to create an archive, but I am not sure if I have to tell Pants explicitly that I want tar executable to be available? Isn’t it available if it’s on the $PATH ?fast-nail-55400
08/20/2021, 3:52 PMfast-nail-55400
08/20/2021, 3:54 PMfast-nail-55400
08/20/2021, 3:55 PMdpkg-deb to display $PATH and whatever else you think relevanthundreds-father-404
08/20/2021, 3:55 PMenv so that PATH includes the path to the tar's first_path. I'm afk but I think if you grep you'll see how that type gets usedenough-analyst-54434
08/20/2021, 4:12 PMchroot command. We hijack the term and do something much less stringent.fresh-cat-90827
08/20/2021, 7:06 PMtar_binary_path = await find_tar()
print({"PATH": tar_binary_path.path})
which gives me
19:01:01.47 [INFO] stdout: "{'PATH': '/usr/bin/tar'}"
19:01:01.47 [INFO] stdout: "\n"
the problem remains:
stderr:
dpkg-deb (subprocess): unable to execute tar -cf (tar): Not a directory
dpkg-deb: error: tar -cf subprocess returned error exit status 2
is passing env={"PATH": tar_binary_path.path}, to the Process() sufficient to expose the executables on the $PATH?fresh-cat-90827
08/20/2021, 7:07 PM"{'PATH': '/usr/bin'}"fresh-cat-90827
08/20/2021, 7:08 PMpathlib should be avoided, but would using Path(tar_binary_path.path).<http://parent.as|parent.as>_posix() be appropriate here?fresh-cat-90827
08/20/2021, 7:08 PM'/usr/bin/tar' to '/usr/bin'hundreds-father-404
08/20/2021, 7:17 PMPath should be avoided, but you can use str(PurePath(tar_binary_path.path).parent) safely!
tar_binary_path = await find_tar()Instead of calling that, put
TarBinary in the signature for your new @rule, which will cause the engine to run the rule find_tar. I'm really surprised await find_tar() worked!fresh-cat-90827
08/20/2021, 7:29 PMdist/ 😄