# Debug a missing dependency

A package declares required dependencies through the arguments to its build
functions. When Kix cannot resolve one of those arguments, evaluation stops
before any manifests are deployed.

## Read the missing argument

Run the cluster checks:

<Command {...check} />

The diagnostic identifies `backend` as the unresolved build argument and
names the consuming instance's namespace. Start with that argument name, not
the Kubernetes resources the package would have rendered.

## Check the package declaration

Find the build entry that accepts the missing argument:

```nix title="packages/gateway/default.nix"
build = { backend, ... }: {
  # Resources that read backend.out values.
};
```

An argument without a default is required. An argument such as
`backend ? null` is optional and does not cause this error when no provider is
available.

## Check the available instances

Kix first looks for an eligible instance with the same name or alias in the
consumer's namespace. Check the cluster definition for spelling changes and
for an instance that was removed or moved.

If the intended provider has another name or lives in another namespace, wire
it explicitly. When the only match is in another namespace, the error already
prints the line to add (`To use it, add this line to instances.<namespace>.<instance>:`),
and when several namespaces answer the name it prints one line per instance:

```nix title="cluster.nix"
instances.apps.gateway = {
  package = packages.gateway;
  deps.backend = ref.platform.api;
};
```

The key after `deps` must match the build argument. The reference selects the
provider by namespace and instance name.

Run the checks again after correcting the name or wiring:

<Command {...checkFixed} />

If Kix reports that the argument matches multiple instances instead, add the
same kind of explicit `deps` entry to the consumer, naming the provider it
should use. See
[Use aliases and default aliases](/docs/how-to/debug-dependency-wiring/use-aliases-and-default-aliases/)
for how names and aliases collide.

:::note[Explanation]
See [Dependency resolution and why explicit deps matter](/docs/explanation/the-dependency-graph/#dependency-resolution-and-explicit-deps)
for the complete lookup order.
:::

:::note[Reference]
See [Build entries](/docs/reference/package-anatomy/#build-entries) and
[`deps`](/docs/reference/instances-and-composition/#deps) for the two sides of the
wiring contract.
:::