bazelbuild / bazelbuild/bazel

mod explain subcommand just prints direct dependencies

Open
#24,960 1 comment 0 reactions 1 assignee Claimed by @Wyverald View on GitHub
P2 team-ExternalDeps type: bug
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Description of the bug:

The documentation for the `explain` subcommand of the `mod` command states the following:

> Shows all the places where the specified modules appear in the dependency graph, along with the modules that directly depend on them. The output of the `explain` command is essentially a pruned version of the `all_paths `command, containing 1) the root module; 2) the root module's direct dependencies that lead to the argument modules; 3) the argument modules' direct dependents; and 4) the argument modules themselves

However when I run this command with some modules that's not a direct dependency, I just end up with a list of all of the direct dependencies (including those that do not lead to the argument module in question). Basically, I get the equivalent of `bazel mod graph --depth=1`.

### Which category does this issue belong to?

CLI

### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

- Check out rules_jvm_external@6.6.
- Run `bazel mod explain rules_pkg`

Output:

```
(rules_jvm_external@6.6)
├───bazel_features@1.18.0
├───bazel_skylib@1.7.1
├───bzlmod_lock_files@_
├───platforms@0.0.10
├───protobuf@27.2
├───rules_android@0.1.1
├───rules_java@7.12.2
├───rules_kotlin@1.9.6
├───rules_license@1.0.0
├───rules_shell@0.3.0
└───stardoc@0.7.0
```

I'd instead expect something like the following:

```
(rules_jvm_external@6.6)
└───protobuf@27.2
└───rules_pkg@0.7.0
```

I believe from what the documentation says there might be more output than the above, but certainly from the examples I wouldn't expect to just get the direct dependencies.

### Which operating system are you running Bazel on?

Linux (Debian testing)

### What is the output of `bazel info release`?

release 7.4.0

### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.

_No response_

### What's the output of `git remote get-url origin; git rev-parse HEAD` ?

```text
git@github.com:bazelbuild/rules_jvm_external.git
664b49e9583d04325fc6f1d8fba38e14fb707c19
```

### If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

_No response_

### Have you found anything relevant by searching the web?

_No response_

### Any other information, logs, or outputs that you want to share?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.