Skip to content

Ask why a module is here

$ grim why payments

There is a directory in src/ you never asked for, and before you touch it you want to know who did. Or grim remove has told you a module stays installed because something still reaches it. grim why answers with a path: from a line in grim.json, through the modules that require one another, down to the one you named.

Usage

$ grim why payments           # the shortest chain, as a tree
$ grim why Payments           # the same; both spellings work
$ grim why payments --json    # every chain, for a script

Run it from the project root. It reads grim.json and grim.lock and nothing else, so it needs no network and the project does not have to be running.

Arguments and options

Explain why a module is installed in this project

Usage

grim why [--json] [--] <module>

Arguments

Argument Description
module Module name (kebab-case or PascalCase) (required)

Options

Option Description
--json Output machine-readable JSON instead of formatted text

What it actually does

  1. Looks the module up in grim.lock. The lock records the requires of every installed module, and that is the graph it searches.
  2. Finds every path from the requires of grim.json to the module.
  3. Prints the shortest one, with the locked version on top.
payments  v2.5.0

shop (project)
└─ cart  (grim.json)
   └─ payments  (requires)

The first step of a chain is marked (grim.json), every later one (requires). A module you required yourself has a chain of one line. When more chains exist it says how many and points at --json, where paths holds all of them. Under Itself requires: it lists what the module pulls in on its own account.

For a module that ships with core there is no chain, and the answer is one sentence: Cart is a core module — bundled with grim-core, not pulled as a separate dependency.

Pitfalls

It reads the lock, not the disk

After a hand edit of grim.json, or after grim remove, which leaves the lock alone, the answer describes the project as it was last locked. Present in grim.lock but unreachable from any grim.json root. means exactly that. Run grim install to write the lock again.

A typo gets suggestions and exit code 1

'paymnts' is not installed in this project. is followed by up to three close names from the lock. The same exit code applies with --json, where the object carries "kind": "unknown".

No lock, no answer

grim.lock not found — run `grim install` first. A project that was never installed has no graph to search.

After it finishes

Nothing has changed. If the chain starts at a line in grim.json you no longer want, grim remove drops that line and clears what it alone held in place. To see the same reasoning for the whole project at once, read the why column of grim install --dry-run.

Recipes that use it