curved-manchester-66006
02/22/2023, 6:13 PMadhoc_tool
But pants tells me (NoApplicableTargetsException) that I can't run
an adhoc_tool
I'm unsure if I'm missing something obvious here or should be looking at another target type (shell_command
?).curved-television-6568
02/22/2023, 6:20 PMRunFieldSet
to get an idea what targets you have that are runnable, but it turns out it was non-obvious what targets those apply to..
pants RunFieldSet --help
13:17:19.62 [INFO] Initializing scheduler...
13:17:23.81 [INFO] Scheduler initialized.
`pants.core.goals.run.RunFieldSet` api type
-------------------------------------------
The fields necessary from a target to run a program/script.
activated by : pants.core
union members: DeployJarFieldSet
DockerRunFieldSet
GoBinaryFieldSet
JavaFieldSet
JvmArtifactFieldSet
PexBinaryFieldSet
PyOxidizerFieldSet
PythonRequirementFieldSet
PythonSourceFieldSet
RunShellCommand
ScalaFieldSet
Include API types and rules dependency information by running `./pants help-advanced pants.core.goals.run.RunFieldSet`.
curved-manchester-66006
02/22/2023, 6:59 PMshell_command
isn't runnable either:
NoApplicableTargetsException: No applicable files or targets matched. The `run` goal works with these target types:
* docker_image
* pex_binary
* python_requirement
* python_source
* python_test
* run_shell_command
So I tried run_shell_command
$ ./pants help run_shell_command
Unknown entity: run_shell_command
:-/
But the ergonomics there are awkward:
run_shell_command(
command="cd {chroot} && ./src.py.foo/bar-cli.pex --help",
and workdir='.'
seems to be ignored.
Still feel like I'm missing something! (2.16.0.dev7)curved-television-6568
02/22/2023, 7:13 PMActivated by pants.backend.shell
curved-manchester-66006
02/22/2023, 7:14 PMbackend_packages = [
"pants.backend.build_files.fmt.black",
"pants.backend.docker",
"pants.backend.docker.lint.hadolint",
"pants.backend.experimental.adhoc",
"pants.backend.experimental.helm",
"pants.backend.python",
"pants.backend.python.mixed_interpreter_constraints",
"pants.backend.python.typecheck.mypy",
"pants.backend.shell"
]
curved-television-6568
02/22/2023, 7:15 PMancient-vegetable-10556
02/22/2023, 7:16 PMancient-vegetable-10556
02/22/2023, 7:17 PMancient-vegetable-10556
02/22/2023, 7:18 PMpants run
ancient-vegetable-10556
02/22/2023, 7:21 PMadhoc_tool
is really only meant for things that are being run for side-effects in the sandbox, not orchestrating tools for use with pants run
Currently the awkwardness of run_shell_command
is your best bet. If there’s weirdness going on with workdir
, it’d be useful if you can file an issue for itcurved-manchester-66006
02/22/2023, 8:20 PM14:52:42.99 [WARN] DEPRECATED: the target name run_shell_command is scheduled to be removed in version 2.18.0.dev0.
Instead, use `run_shell_command`, which behaves the same. Run `./pants update-build-files` to automatically fix your BUILD files.
Since I think https://github.com/pantsbuild/pants/commit/51de7e7a873984e5ea17ac4f7d45e14447a7a593 already fixed that