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

MGS1047: a spell import resolves outside the workspace

A spell import is searched from the workspace root down to the directory of the magusfile that imports it. A ../ import joined onto a shallow level can point above the root, and magus never loads a file from there:

[error] [MGS1047] import "../spells/lint" resolves outside the workspace: from /repo
it reaches above the workspace root /repo, and an import never loads a file outside
the root; import a path inside the workspace

A candidate above the root is skipped without being probed. The error fires only when no candidate inside the root is left.

A plain module import is held to the same root. A file the search resolves above the root is refused with this code and never read. The remote-spell view is a declared root and stays allowed, and -L or BUZZ_INCLUDE_PATH for magus buzz scripts stay a deliberate escape.

Why

The workspace is the unit magus loads, caches and sandboxes. A worktree sits beside other checkouts of the same repository, and an import that reached past its root would load a sibling checkout's spell, so two checkouts of one commit could run different code. Keeping the search inside the root is what makes a load answer for its own tree.

What to do

Import the spell by a path that stays inside the workspace, relative to the magusfile or to the workspace root. A spell that lives outside the repository is declared through magus.yaml instead; see Remote spells.

MGS1047magusfilespellsimportsworkspacehermetic
Last updated (683bb672)
Glossary

Workspace

The magus root directory that owns a set of projects and shared config; the unit magus operates over. See workspace.

Magusfile

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

Spell

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

Module

A magus stdlib namespace a magusfile imports for host capabilities: filesystem, exec, vcs, and more. See the module reference.

Buzz

The language magusfiles are written in (the .buzz engine). See engines.

Cache

The content-addressed store magus consults before running a target, so unchanged work is skipped. See cache.

Sandbox

The restricted filesystem and environment a target runs in, so builds stay reproducible and side-effect-free. See sandbox.

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.

Conventions

This page uses none of the site's convention markers. The full set is on the conventions page.