Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

deps

Show import dependencies for a file, including what it imports and what depends on it.

Synopsis

bobbin deps [OPTIONS] <FILE>

Description

The deps command queries the bobbin metadata store to display import relationships for a given file. By default it shows forward dependencies (what the file imports). With --reverse it shows reverse dependencies (files that import this file). Use --both to see both directions at once.

Dependencies are extracted during indexing from import, use, require, and similar statements depending on the language. Resolved paths show the actual file on disk; unresolved imports are marked accordingly.

Arguments

ArgumentDescription
<FILE>File to show dependencies for (required)

Options

OptionShortDescription
--reverse-rShow reverse dependencies (files that import this file)
--both-bShow both directions (imports and dependents)

Examples

Show what a file imports:

bobbin deps src/main.rs

Show what files depend on a module:

bobbin deps --reverse src/config.rs

Show both imports and dependents:

bobbin deps --both src/lib.rs

JSON output for scripting:

bobbin deps --json src/main.rs

JSON Output

When --json is passed, the output has this structure:

{
  "file": "src/main.rs",
  "imports": [
    {
      "specifier": "use crate::config::Config",
      "resolved_path": "src/config.rs"
    }
  ],
  "dependents": null
}

With --reverse or --both, the dependents array is populated:

{
  "file": "src/config.rs",
  "imports": null,
  "dependents": [
    {
      "specifier": "use crate::config::Config",
      "source_file": "src/main.rs"
    }
  ]
}

Fields that are null are omitted from the JSON.

Prerequisites

Requires a bobbin index. Run bobbin init and bobbin index first.

See Also

  • refs — find symbol references across the index
  • related — find files related to a given file