Skip to content

fix: derive all toolchain repo names from a single base name - #74

Open
sallustfire wants to merge 1 commit into
bazel-contrib:mainfrom
sallustfire:fix/jq-host-alias-dangling-symlink
Open

fix: derive all toolchain repo names from a single base name#74
sallustfire wants to merge 1 commit into
bazel-contrib:mainfrom
sallustfire:fix/jq-host-alias-dangling-symlink

Conversation

@sallustfire

Copy link
Copy Markdown

When jq.bzl is consumed as a standalone bazel_dep, use_repo(toolchains, "jq") produces a @jq repo with a dangling symlink.

The _toolchains_extension creates platform repos with prefix jq_toolchains (e.g. jq_toolchains_linux_amd64), but jq_host_alias_repo(name = "jq") constructs its symlink using rctx.attr.name, targeting ../jq_linux_amd64/jq which doesn't exist.

This is masked when jq.bzl is consumed through aspect_bazel_lib, which creates platform repos with the jq prefix.

The fix introduces a single local variable in the extension from which all repo names are derived, so the platform repo prefix, the user_repository_name passed to jq_toolchains_repo, and the host alias name are always consistent.

bazel_dep(name = "jq.bzl", version = "0.6.0")
toolchains = use_extension("@jq.bzl//jq:extensions.bzl", "toolchains")
use_repo(toolchains, "jq", "jq_toolchains")
# @jq//:jq now resolves correctly

Changes are visible to end-users: yes

  • Searched for relevant documentation and updated as needed: no
  • Breaking change (forces users to change their own code or config): no
  • Suggested release notes appear below: yes

Fixed: jq_host_alias_repo now resolves correctly when jq.bzl is used as a standalone bazel_dep. Previously, use_repo(toolchains, "jq") produced a dangling symlink because the platform repos were named jq_toolchains_{platform} while the host alias expected jq_{platform}. Platform repos are now named jq_{platform} to match.

Test plan

  • New test cases added
    • jq_host_alias_test exercises the @jq host alias repo via use_repo(toolchains, "jq"), verifying the symlink resolves and the binary executes

@aspect-workflows

aspect-workflows Bot commented Mar 12, 2026

Copy link
Copy Markdown

Bazel 7 (Test)

1 test target passed

Targets
//jq/tests:check_stamped [k8-fastbuild] 52ms

Total test execution time was 52ms. 11 tests (91.7%) were fully cached saving 803ms.


Bazel 8 (Test)

1 test target passed

Targets
//jq/tests:check_stamped [k8-fastbuild] 66ms

Total test execution time was 66ms. 11 tests (91.7%) were fully cached saving 690ms.


Bazel 9 (Test)

1 test target passed

Targets
//jq/tests:check_stamped [k8-fastbuild] 82ms

Total test execution time was 82ms. 11 tests (91.7%) were fully cached saving 656ms.


Bazel 7 (Test)

e2e/smoke

All tests were cache hits

3 tests (100.0%) were fully cached saving 111ms.


Bazel 8 (Test)

e2e/smoke

All tests were cache hits

3 tests (100.0%) were fully cached saving 158ms.


Bazel 9 (Test)

e2e/smoke

All tests were cache hits

3 tests (100.0%) were fully cached saving 180ms.

jq_host_alias_repo(name = "jq") builds its symlink using rctx.attr.name,
producing ../jq_{platform}/jq. But the extension created platform repos
with prefix "jq_toolchains", so the actual sibling was
jq_toolchains_{platform} — a dangling symlink.

Introduce a local `name` variable in the extension and derive all repo
names from it, so the platform repo prefix, the toolchains repo
user_repository_name, and the host alias name are always consistent.
@sallustfire
sallustfire force-pushed the fix/jq-host-alias-dangling-symlink branch from 00e3a2c to 56f48f2 Compare March 13, 2026 03:16
@sallustfire

Copy link
Copy Markdown
Author

@alexeagle Any chance you or someone else can look at what's hopefully an innocuous bugfix or at least make sure it doesn't get lost in the rennovate backlog?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant