Is there a way I can use something I extracted wit...
# general
p
Is there a way I can use something I extracted with a shell_command as a runnable in an adhoc_tool? As far as I can tell this is not allowed In particular, I and grabbing a http_source and untaring it. I'd like to use the adhoc tool to create a resource to be used by a pythonsource.
Copy code
file(
    name="downloaded-sass",
    source=per_platform(
        macos_x86_64=http_source(
            url="<https://github.com/sass/dart-sass/releases/download/1.69.5/dart-sass-1.69.5-macos-x64.tar.gz>",
            len=3457742,
            sha256="75e29a5bd76069abf2532c9a4b36b164f1c91a461452f0fbdc4167fd1685550c",
            filename="sass.tar.gz",
        ),
        linux_x86_64=http_source(
            url="<https://github.com/sass/dart-sass/releases/download/1.69.5/dart-sass-1.69.5-linux-x64.tar.gz>",
            len=3697303,
            sha256="42b3d7b82098432f80d057da5e7464e96e6cd8d90827a9e3a47974f39c930218",
            filename="sass.tar.gz",
        ),
    ),
)

shell_command(
    name="extracted-sass",
    command="tar -zxvf sass.tar.gz",
    tools=["tar", "gzip"],
    execution_dependencies=[":downloaded-sass"],
    output_directories=["dart-sass"],
    root_output_directory="./dart-sass"
)

run_shell_command(
    name="sass",
    command="XDG_CONFIG_DIRS=${CHROOT}:$XDG_CONFIG_DIRS {chroot}/sass $@",
    workdir="/",
    execution_dependencies=[":extracted-sass"],
)
@bitter-ability-32190 You inspired me with this https://pantsbuild.slack.com/archives/C0D7TNJHL/p1694197694977719
But when I try to run this
Copy code
adhoc_tool(
    name="css",
    runnable="//third_party/sass",
    args = ["--style", "compressed", "style/style.css", "static/style.css"],
    execution_dependencies=[":style"],
    output_directories=["static"],
    root_output_directory="."
)

archive(name="archive", files=[":css"], format="zip")
I get
Copy code
NotImplementedError: Running this target type within the sandbox is not yet supported.
b
That might've been on a branch where I had changed that value
p
Ahhh. yeah I see that I have to specify runnable and it can't be run_shell_command.
l
Gee, my impression was that you can use
shell_command
rather than
run_shell_command
to generate and wrap sources. https://pantsbuild.slack.com/archives/C046T6T9U/p1680709417133039?thread_ts=1674580234.158039&amp;cid=C046T6T9U and such
like,
adhoc_tool
does codegen for everything but shell commands, but you can use
shell_command
independently for codegen that you can capture.
p
I ended up getting it to work with a shell command calling npm. I was trying to chain two shell commands together, one to untar and the other to run. For some reason the second one wouldn’t execute.