aspect-build / aspect-cli

correct, fast, usable: choose three
https://aspect.build/cli
Apache License 2.0
93 stars 21 forks source link

[Bug]: cli does not forward an empty arguments #771

Closed r0bobo closed 2 weeks ago

r0bobo commented 2 weeks ago

What happened?

Aspect cli does not forward an empty argument when running bazel mod dump_repo_mapping "". This is used by starpls to fetch external dependencies with bzlmod. This works with bazelisk but breaks with aspect cli.

The following patch fixes the problem:

diff --git a/pkg/aspect/root/flags/interceptor.go b/pkg/aspect/root/flags/interceptor.go
index 6c2beee..bc4a3d5 100644
--- a/pkg/aspect/root/flags/interceptor.go
+++ b/pkg/aspect/root/flags/interceptor.go
@@ -60,6 +60,7 @@ func FlagsInterceptor(streams ioutils.Streams) interceptors.Interceptor {
            doubleDash := false
            for _, arg := range args {
                if arg == "" {
+                   forwardArgs = append(forwardArgs, arg)
                    continue
                }
                if arg == "--" {

I am unsure whether this causes trouble with other parts of aspect cli however.

Version

Development (host) and target OS/architectures:

Output of bazel --version: bazel 7.4.0

Version of the Aspect rules, or other relevant rules from your WORKSPACE or MODULE.bazel file:

Language(s) and/or frameworks involved:

How to reproduce


# with bazelisk

❯ bzl mod dump_repo_mapping ""
{"":"","remotejdk17_linux_s390x_toolchain_config_repo":"remotejdk17_linux_s390x_toolchain_config_repo","rules_multitool":"rules_multitool~","remotejdk21_macos_aarch64_toolchain_config_repo":"remotejdk21_macos_aarch64_toolchain_config_repo","rules_java_builtin":"rules_java_builtin","remotejdk17_linux_aarch64_toolchain_config_repo":"remotejdk17_linux_aarch64_toolchain_config_repo","remotejdk17_linux_toolchain_config_repo":"remotejdk17_linux_toolchain_config_repo","remote_java_tools_windows":"remote_java_tools_windows","remotejdk11_win_toolchain_config_repo":"remotejdk11_win_toolchain_config_repo","remotejdk21_linux_ppc64le":"remotejdk21_linux_ppc64le","remotejdk11_linux_aarch64":"remotejdk11_linux_aarch64","platforms":"platforms","remotejdk17_linux":"remotejdk17_linux","remotejdk11_linux_s390x_toolchain_config_repo":"remotejdk11_linux_s390x_toolchain_config_repo","remotejdk17_macos":"remotejdk17_macos","remotejdk21_macos_toolchain_config_repo":"remotejdk21_macos_toolchain_config_repo","rules_java":"rules_java","remotejdk17_win":"remotejdk17_win","rules_python":"rules_python","remote_jdk8_linux_toolchain_config_repo":"remote_jdk8_linux_toolchain_config_repo","remotejdk11_linux_ppc64le_toolchain_config_repo":"remotejdk11_linux_ppc64le_toolchain_config_repo","internal_platforms_do_not_use":"internal_platforms_do_not_use","remote_jdk8_windows":"remote_jdk8_windows","remote_jdk8_linux_s390x":"remote_jdk8_linux_s390x","remote_jdk8_macos_aarch64":"remote_jdk8_macos_aarch64","buildifier_prebuilt":"buildifier_prebuilt~","remotejdk17_win_arm64_toolchain_config_repo":"remotejdk17_win_arm64_toolchain_config_repo","remotejdk11_linux":"remotejdk11_linux","remotejdk11_macos_toolchain_config_repo":"remotejdk11_macos_toolchain_config_repo","android_tools":"android_tools","rules_proto":"rules_proto","remotejdk17_win_arm64":"remotejdk17_win_arm64","rules_cc":"rules_cc","remotejdk17_linux_ppc64le":"remotejdk17_linux_ppc64le","remotejdk21_win_arm64_toolchain_config_repo":"remotejdk21_win_arm64_toolchain_config_repo","remote_jdk8_macos":"remote_jdk8_macos","remotejdk21_linux_s390x_toolchain_config_repo":"remotejdk21_linux_s390x_toolchain_config_repo","__main__":"","local_jdk":"local_jdk","remote_java_tools_darwin_x86_64":"remote_java_tools_darwin_x86_64","remote_jdk8_macos_aarch64_toolchain_config_repo":"remote_jdk8_macos_aarch64_toolchain_config_repo","yq_toolchains":"aspect_bazel_lib~~toolchains~yq_toolchains","rules_cue":"rules_cue~","remote_java_tools":"remote_java_tools","remotejdk17_win_toolchain_config_repo":"remotejdk17_win_toolchain_config_repo","remotejdk21_linux_toolchain_config_repo":"remotejdk21_linux_toolchain_config_repo","local_config_platform":"local_config_platform","remotejdk17_macos_toolchain_config_repo":"remotejdk17_macos_toolchain_config_repo","remote_jdk8_macos_toolchain_config_repo":"remote_jdk8_macos_toolchain_config_repo","rules_license":"rules_license","remotejdk21_macos_aarch64":"remotejdk21_macos_aarch64","remote_jdk8_linux_s390x_toolchain_config_repo":"remote_jdk8_linux_s390x_toolchain_config_repo","remotejdk17_macos_aarch64":"remotejdk17_macos_aarch64","remote_jdk8_linux_aarch64_toolchain_config_repo":"remote_jdk8_linux_aarch64_toolchain_config_repo","remotejdk11_win":"remotejdk11_win","multitool":"rules_multitool~~multitool~multitool","host_platform":"host_platform","remote_jdk8_linux":"remote_jdk8_linux","bazel_skylib":"bazel_skylib","remotejdk11_linux_toolchain_config_repo":"remotejdk11_linux_toolchain_config_repo","remotejdk11_macos":"remotejdk11_macos","remotejdk11_win_arm64":"remotejdk11_win_arm64","remotejdk21_macos":"remotejdk21_macos","remotejdk17_macos_aarch64_toolchain_config_repo":"remotejdk17_macos_aarch64_toolchain_config_repo","remote_jdk8_linux_aarch64":"remote_jdk8_linux_aarch64","local_config_cc":"local_config_cc","remotejdk11_macos_aarch64_toolchain_config_repo":"remotejdk11_macos_aarch64_toolchain_config_repo","remotejdk21_linux":"remotejdk21_linux","android_gmaven_r8":"android_gmaven_r8","remote_java_tools_linux":"remote_java_tools_linux","remotejdk21_win":"remotejdk21_win","remotejdk21_linux_aarch64":"remotejdk21_linux_aarch64","remotejdk11_linux_aarch64_toolchain_config_repo":"remotejdk11_linux_aarch64_toolchain_config_repo","remotejdk11_linux_s390x":"remotejdk11_linux_s390x","remotejdk17_linux_aarch64":"remotejdk17_linux_aarch64","local_config_sh":"local_config_sh","remotejdk21_linux_s390x":"remotejdk21_linux_s390x","remotejdk21_win_arm64":"remotejdk21_win_arm64","remotejdk17_linux_ppc64le_toolchain_config_repo":"remotejdk17_linux_ppc64le_toolchain_config_repo","remote_java_tools_darwin_arm64":"remote_java_tools_darwin_arm64","remotejdk21_linux_ppc64le_toolchain_config_repo":"remotejdk21_linux_ppc64le_toolchain_config_repo","remotejdk21_linux_aarch64_toolchain_config_repo":"remotejdk21_linux_aarch64_toolchain_config_repo","remotejdk11_win_arm64_toolchain_config_repo":"remotejdk11_win_arm64_toolchain_config_repo","bazel_tools":"bazel_tools","remote_coverage_tools":"remote_coverage_tools","aspect_rules_lint":"aspect_rules_lint~","aspect_bazel_lib":"aspect_bazel_lib~","local_config_cc_toolchains":"local_config_cc_toolchains","remote_jdk8_windows_toolchain_config_repo":"remote_jdk8_windows_toolchain_config_repo","remotejdk17_linux_s390x":"remotejdk17_linux_s390x","local_config_xcode":"local_config_xcode","remotejdk11_linux_ppc64le":"remotejdk11_linux_ppc64le","remotejdk11_macos_aarch64":"remotejdk11_macos_aarch64","remotejdk21_win_toolchain_config_repo":"remotejdk21_win_toolchain_config_repo"}

# with aspect-cli through `.bazeliskrc`

❯ cat <<EOF > .bazeliskrc
BAZELISK_BASE_URL=https://github.com/aspect-build/aspect-cli/releases/download
USE_BAZEL_VERSION=aspect/2024.44.3
EOF

❯ bzl mod dump_repo_mapping ""
ERROR: No repository name(s) specified. Type 'bazel help mod' for syntax and help.

Any other information?

No response