Skip to content
BETAGuardrails are in beta. The library, the configuration format and the CLI command can still change.

Guardrails / elixir

Elixir version is declared

elixir/version-declared@v1

The project declares the Elixir version it is compiled against, and that version is no older than the configured floor.

Idelixir/version-declared
Versionv1
Categoryelixir
Default severitywarning
Interpreterpython3
Timeout30 seconds
Violations tolerated0
Collectselixir

Collectors

This guardrail gathers nothing itself. It depends on the collectors below, which the CLI runs once per build before any check, and reads what they found out of GUARDRAIL_FACTS. A collector that collects nothing skips this guardrail rather than failing it.

CollectorGathersInputs it is given
elixirThe Mix build in the project directory: the application it declares, the Elixir version it asks for, every application of an umbrella, the dependencies each manifest names with their environments and origins, and the lock file beside them. mix.exs is Elixir rather than a declaration, so what it declares conditionally is not seen and scanned says so.projectDir

The inputs above are this guardrail's own, passed straight through. Configuring one in buildnote.json changes what is collected, and two guardrails configured the same way share the one collection.

Configuration

json
{
  "guardrails": {
      "failOn": "error",
      "comment": true,
      "checks": [
          {
              "use": "elixir/version-declared@v1",
              "severity": "warning",
              "with": {
                  "projectDir": ".",
                  "minVersion": "1.14"
              },
              "exemptions": []
          }
      ]
  }
}

Inputs

InputDescriptionDefaultEnvironment variable
projectDirDirectory holding the project, relative to the directory the CLI runs in..GUARDRAIL_INPUT_PROJECTDIR
minVersionOldest Elixir version accepted. A declared version below this is a violation.1.14GUARDRAIL_INPUT_MINVERSION

How to fix

Declare the compiler where the project already declares itself, in the project function of mix.exs:

elixir
def project do
  [
    app: :widget,
    version: "1.2.3",
    elixir: "~> 1.16"
  ]
end

Without it Mix compiles with whatever Elixir the runner happens to carry, so a macro or standard library difference between releases reaches CI rather than the laptop that introduced it.

More in elixir

All 3 elixir guardrails

Buildnote Limited
Registered in England and Wales, Reg: 16140412