rules_apko icon indicating copy to clipboard operation
rules_apko copied to clipboard

pass correct apko binary runfiles path to apko_run launcher

Open Strum355 opened this issue 1 year ago • 2 comments

In https://github.com/sourcegraph/sourcegraph, we've defined our own apko toolchain to integrate a patch to go-apk for the apko binary. Due to this, we pass register = False to apko_register_toolchains.

This surfaced a correctness issue when trying to run bazel run @rules_apko//apko, with the following error:

INFO: Running command line: bazel-bin/external/rules_apko/apko/_apko_run.sh
Workdir: /home/noah/Sourcegraph/sourcegraph
/home/noah/.cache/bazel/_bazel_noah/8fd1d20666a46767e7f29541678514a0/execroot/__main__/bazel-out/k8-fastbuild/bin/external/rules_apko/apko/_apko_run.sh: line 11: /home/noah/.cache/bazel/_bazel_noah/8fd1d20666a46767e7f29541678514a0/execroot/__main__/bazel-out/k8-fastbuild/bin/external/rules_apko/apko/_apko_run.sh.runfiles/__main__/bazel-out/k8-opt-exec-ST-13d3ddad9198/bin/external/dev_chainguard_apko/apko_/apko: No such file or directory

From the bazel docs on runfiles location, this particular quote highlights the correct way to build the path to the apko binary's runfile path: "The path to a File under the runfiles directory corresponds to File.short_path."

The change presented works both for our case, and also bazel run //apko:apko in the rules_apko repo :slightly_smiling_face:

Strum355 avatar Mar 13 '24 17:03 Strum355

can you sign your commits?

thesayyn avatar Mar 25 '24 20:03 thesayyn

can you sign your commits?

done 👍

Strum355 avatar Mar 25 '24 22:03 Strum355

ping

keegancsmith avatar Nov 13 '24 18:11 keegancsmith