---
title: "MGS1022: member only callable from a magusfile"
description: Fires when a magus buzz script calls a magus namespace member that declares into, or reads from, the workspace magus is loading. The rest of the namespace works in a script.
tags: [MGS1022, magusfile, buzz, scripts, namespace]
---

# MGS1022: member only callable from a magusfile

A `magus buzz` script called a `magus\*` member that only a magusfile can serve.

```text
[MGS1022] magus\project: only callable from a magusfile, not a magus buzz script
  - it declares into the workspace magus is loading, and a script has none
```

`import "magus"` resolves everywhere Buzz runs, and most of the namespace works
in a script. Two groups do not, for two different reasons.

## Members that declare into a workspace

`magus\project`, `magus\cache.remote`, and `magus\ci.provider` record onto the
registry magus builds while it loads a workspace. Evaluating a magusfile creates
that registry. Nothing loads a script into a workspace, so a declaration made
there has nowhere to land.

There is no script-side equivalent, because there is nothing to declare. Put the
declaration in the `magusfile.buzz` of the project it describes.

## Members that read a loaded workspace

`magus\ls`, `magus\targets`, `magus\affected`, `magus\graph`, and `magus\where`
answer from the workspace already open on the context, which is what makes them
free of a subprocess. A script has no workspace open.

These do have a script-side equivalent: the members that run a nested `magus`,
which discovers the workspace root itself.

```buzz
import "std";
import "magus";

fun main() > void {
    // magus\ls() raises MGS1022 here; the nested command does not.
    final projects = magus\describe(["projects", "-o", "json"], opts: {"quiet": true});
    std\print(projects.stdout);
}
main();
```

`magus\cmd`, `magus\run`, `magus\describe`, `magus\insight`, and `magus\doctor`
all work this way, and so does the rest of the namespace: `magus\normalize`,
`magus\module` / `magus\modules`, and the log levels
(`magus\info`/`debug`/`warn`/`error`).

## Why the import resolves at all

`import "magus"` used to fail outright in a script. You would read that as "there
is no such module" and go looking for one that does not exist. Failing at the
member instead names the rule you actually hit and leaves the rest of the
namespace reachable, the way `vcs\isDirty` raises when no VCS is resolved while
the `vcs` module stays where it is.

## See also

- [magus module](../../buzz/magus.md): every member, and what each one needs.
- [Debugging](../../../guides/debugging.md#interactive-repl): the REPL, which does
  load a magusfile - `magus buzz` with no arguments.
