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

MGS2006: likely PATH-shim manager stripped

A subprocess failed and magus suspects the cause is sandbox stripping the env vars that a PATH-shim runtime manager (mise, asdf, direnv) relies on.

[MGS2006] mise shims appear stripped from PATH; the build is using system tools instead
  cmd=go missing_var=MISE_DATA_DIR

Why

mise, asdf, and direnv work by injecting a shim directory into PATH and reading a tool-version file from the workspace. The shim binary is invoked when the user runs go, then mise looks at its own MISE_* env vars to decide which Go version to dispatch to.

When sandbox strips MISE_* (or ASDF_*, DIRENV_*) from the child's environment, the shim runs without configuration and either fails or falls back to a system tool the user did not intend to use.

Resolution

Add the variables your runtime manager needs to sandbox.env.passthrough:

sandbox:
  env:
    passthrough:
      - "MISE_*" # mise
      - "ASDF_*" # asdf
      - "DIRENV_*" # direnv

Pick the one (or two) you actually use. The wildcard is a suffix match so MISE_* covers MISE_DATA_DIR, MISE_SHIMS, __MISE_*, etc.

These variables do not, by themselves, contain credentials a supply-chain attacker would target. They configure a local tool manager. Adding them to the passthrough list does not weaken sandbox's secret-protection guarantee.

If you do not use a PATH-shim manager and this code fires, the heuristic is wrong; please file an issue with the parent PATH and the failing command.

MGS2006sandboxmiseasdfdirenvPATHshimspassthrough
Last updated (b022d75e)
Glossary

Workspace

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

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. See targets.

Sandbox

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

CI

An ordinary magusfile-defined target you compose yourself with magus\needs - magus does not hardcode its stages. Magus.RunCI treats it specially only in that it strips the rw charm, it is the anchor magus affected ci keys off, and a selected scope with no project declaring it is a load error rather than a silent no-op. See targets.

Conventions

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