I'm trying to run a utility that generates a file ...
# general
s
I'm trying to run a utility that generates a file with a python runnable and copies it from the pants sandbox back to the repo disk space:
Copy code
python_sources(name="src")

adhoc_tool(
    name="retrieve_answer_tool",
    runnable="retrieve_answers.py:src",
    output_files=["answers.json"],
)

run_shell_command(
    name="write-answers",
    command="cp {chroot}/{path_to_answers}/answers.json answers.json",
    runnable_dependencies=["retrieve_answers.py:src"],
)
doing
pants run :write-answers
Getting:
Copy code
ResolveError: The file or directory 'retrieve_answers.py' does not exist on disk in the workspace, so the address 'retrieve_answers.py:src' from the `runnable_dependencies` from the target {redacted}/utils:write-answers cannot be resolved.
Any idea what I'm doing wrong?
creating a pex_binary seems to be cooperating
g
You can just set retrieve_answers.py as execution_dependency and run it with python if you don't need any lockfile deps in retrieve_answers.py.
Haven't used adhoc_tool, but you should probably change
runnable
to something that can be run with
pants run
. So,
pants run path/to/retrieve_answers.py