magus v0.4.3 is out. See what's new
¶ View markdown source · ✎ Suggest an edit
2 min read

MGS1006: unknown target

A target was referenced by a name that no project in scope declares. This happens two ways:

  • A CLI call such as magus run <name> (or magus x <name>) where <name> matches no target anywhere in the selected scope.
  • A dependency handle in a magusfile, such as ctx.needs(<name>), that names a target that does not exist.
[MGS1006] magusfile: unknown target "build" (registered: build, lint, test)
  see: .../MGS1006.md

Why

A target is an exported function in a magusfile (normalized to a kebab-case name). Magus resolves a referenced target by that name; when nothing declares it, there is nothing to run. The message lists the targets that ARE registered in scope so a typo is obvious at a glance.

During a normal fan-out run (magus run build, magus affected ci), a project that does not declare the requested target is silently skipped, not reported as unknown; that is expected in a multi-project workspace. MGS1006 is the terminal case: the name resolves to no target at all in the selected scope.

Resolution

  • Typo? Compare against the registered: list in the message, or run magus describe targets to see every target and the project that declares it.

  • Wrong scope? The target may live in a project outside the current selection. Run from the workspace root, or widen the scope.

  • Not defined yet? Declare it as an exported function in the project's magusfile:

    import "magus";
    
    export fun build(ctx: magus\Context, _a: [str]) > void { go["go-build"](ctx); }
    
  • Dependency handle. ctx.needs(x) takes a target FUNCTION handle in the same magusfile; a cross-project dependency uses the imported project's handle (import "project/api"; ... ctx.needs(api.build);). A bare unresolved name raises this diagnostic.

What this is not

  • Not a missing spell. A spell provides ops, not targets. If the name you meant is a spell op, invoke it through a target, not directly.
  • Not the empty-affected-set no-op. magus affected ci with no changed projects runs nothing and does not raise MGS1006.

See also

  • targets: the anatomy of a magus target.
  • magus describe targets: every target and where it is declared.
MGS1006magusfiletargetsneedsdependsauthoring
Last updated (353014be)
Earlier changes on this page (7)

Full history ↗ · Blame source ↗

Glossary

Workspace

The magus root directory that owns a set of projects and shared config; the unit magus operates over. Workspace in full.

Project

A directory magus recognizes as a unit of work (it has a magusfile); the unit of caching, scheduling, and dependency tracking. Project in full.

Magusfile

The magusfile.buzz that declares a project's targets (as export funs) and binds its spells. Magusfile in full.

Target

A named operation (build, test, ...) you invoke with magus run <target>; it may compose a spell's tool-native operations and depend on other targets. Target in full.

Op

A single tool-native command a target composes (long form: operation); the middle of the work hierarchy (Spell to Op to Target). Op in full.

Spell

A language/runtime adapter (e.g. go, md) that maps generic targets onto a toolchain's real commands. Spell in full.

Buzz

The language magusfiles are written in (the .buzz engine). Buzz in full.

Affected

The set of projects touched by a change; magus affected <target> runs a target only over them. Affected in full.

CI

An ordinary target you compose yourself with ctx.needs; magus does not hardcode its stages. It is the anchor magus affected ci keys off, and ci strips the rw charm. CI in full.

Run

One target executing under one magus invocation, such as magus run test web or magus affected ci. A run keeps its captured output behind an output reference. Every magus run is a run whether or not any job asked for it; see Job for how the two relate. Run in full.

Conventions

Placeholders

Angle brackets mark a value you replace with your own; never type the brackets:

magus run <target>
magus completion <shell>    # e.g. bash, zsh, fish

<target>, <path>, <shell>, <name> and the like are stand-ins, not literal text.