[Bug]: buildifier_prebuilt declared as dev_dependency, yet used unconditionally

Open Beginner friendly
#3,921 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Domain
build-system

Research direction

Start with the top-level BUILD file and MODULE.bazel, then reproduce the failure with bazel query @rules_nodejs//:all-targets using rules_nodejs 6.7.3. Determine how the dev-only buildifier_prebuilt declaration conflicts with the unconditional load, and verify that a clean consumer repository can query the external targets successfully.

Written by the indexing model from the issue text.

Description

bug
What happened?

Starting in 6.7.3, the rules_nodejs MODULE.bazel declares buildifier_prebuilt as a dev dependency.
However, the top-level BUILD file unconditionally load()s from @buildifier_prebuilt.

When I updated my repo to consume rules_nodejs 6.7.3, I discovered that I could not access the repo at all:

$ bazel query @rules_nodejs//:all-targets
[...]
(11:06:14) ERROR: error loading package '@@rules_nodejs+//': Unable to find package for @@[unknown repo 'buildifier_prebuilt' requested from @@rules_nodejs+]//:rules.bzl: The repository '@@[unknown repo 'buildifier_prebuilt' requested from @@rules_nodejs+]' could not be resolved: No repository visible as '@buildifier_prebuilt' from repository '@@rules_nodejs+'.

One way to work around this would be to simply delete the use of buildifier_prebuilt from this repo. I came up with a patch to do that.
I believe that another way would be to make buildifier_prebuilt not be a dev dependency.

I have no preference, but I think it would be good to resolve the impedance mismatch.

Version

Development (host) and target OS/architectures:
Ubuntu 24.04, amd64

Output of bazel --version:
8.3.1

Version of rules_nodejs, or other relevant rules from your
WORKSPACE or MODULE.bazel file:
6.7.3

Language(s) and/or frameworks involved:

How to reproduce
Create a repo with a MODULE.bazel as follows:

bazel_dep(name = "rules_nodejs", version = "6.7.3")`


Then try `bazel query @rules_nodejs//:all-targets`
Any other information?

No response

Dominant language
Starlark
Stars
762
Forks
531
Avg merge
10h 31m
Merged PRs (30d)
3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bazel-contrib/rules_nodejs

All issues in bazel-contrib/rules_nodejs

Similar issues

More Build System issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.