cooldown

Hex

On this page

cooldown gates Elixir projects through --tool hex (aliases mix, elixir).

What it reads#

A Hex project is a mix.exs with its mix.lock. cooldown reads an aliased dependency, such as {:parsec, "~> 1.2", hex: :nimble_parsec}, under its Hex package.

In an umbrella, a dependency any app under apps/ declares from Hex is direct. A declaration from a path, Git or sibling app makes no Hex entry direct. Rows name no app, since an app’s sibling and path dependencies are in no lock entry, and pins, bounds and overrides are read from the root mix.exs alone.

cooldown reads each dependency’s requirement where the root mix.exs’s deps list spells it as a string literal:

  • One exact version, == 1.2.3 or a bare "1.2.3": holds the dependency as pinned.
  • Any other requirement: keeps its target inside it, ~> 1.1.0 within 1.1.

A transitive another package pins exactly is held by that package, and moves when the same batch moves it, unless the project’s own declaration sets override: true. A lock entry nothing requires any more still holds until mix deps.unlock --unused removes it.

Registry#

Publish times come from hex.pm. cooldown plans only packages Hex fetches from hex.pm itself, so none from a private organization or repository, Git or path source.

How it is driven#

cooldown runs mix, or the program COOLDOWN_MIX names.

upgrade and fix relock with mix in a scratch directory and publish only mix.lock, so deps/ and _build/ stay as they were until the next mix deps.get. They:

  • need Elixir >= 1.15.6 and Hex >= 2.5.2, exercised with Elixir 1.20 and Hex 2.5 to 2.7;
  • turn off Hex’s own cooldown and policy for the relock;
  • refuse while a mirror or another repository stands in for hex.pm.

A preview with --dry-run refuses a project whose path dependency lies outside it, which the preview’s copy of the project leaves behind.

check proves mix.lock current with Mix’s own mix deps.get --check-locked, which fetches and builds every dependency in scratch directories, so deps/ and _build/ stay as they were. It needs Elixir >= 1.15 and hex.pm. A lock Mix refuses as out of date is stale, which --allow-stale-lock waives.

--build runs mix deps.get --check-locked in the project, which fetches exactly the locked versions.

Edge cases#

Two cases stay outside the relock’s scratch directory:

  • A Git dependency the relock fetches: can have Mix fetch its own dependencies outside the scratch directory, as a plain mix deps.get would. cooldown then refuses the relock, but cannot undo that fetch.
  • An umbrella that keeps its apps elsewhere than apps/ (apps_path): can have a member’s mix.exs change while cooldown relocks without cooldown noticing.

check fetches from hex.pm, so under --offline the lock is lock_unknown. The lock is also lock_unknown when:

  • the project names another lock or has a Git dependency;
  • a path dependency’s source is missing;
  • Hex keeps its home inside the project;
  • Mix would fetch or build a dependency outside the scratch directories.

Fixing what goes wrong#

  • A dependency held by its requirement: the relock never edits mix.exs, so --rewrite does not lift such a requirement. Loosen it yourself.
  • A stale entry nothing requires: run mix deps.unlock --unused.
Esc

Type # for headings only ↑↓ move ↵ open Ctrl ↵ new tab Ctrl U/D scroll preview

Keyboard shortcuts

/ ⌘ K Ctrl K
Search
← →
Previous or next page
?
Show these shortcuts