Skip to content
Latchkey

Elixir "** (Mix) Could not find a Mix.Project" in CI

mix looks for a mix.exs in the current directory (and up) to load the project. When the CI step runs from a folder without one, mix aborts before doing anything.

What this error means

A mix command fails with "** (Mix) Could not find a Mix.Project, please ensure you are running Mix in a directory with a mix.exs file".

** (Mix)
** (Mix) Could not find a Mix.Project, please ensure you are running Mix in a
directory with a mix.exs file

Common causes

Wrong working-directory for the app

The Elixir project lives in a subfolder (a monorepo, or an umbrella child), but the step runs from the repo root where there is no mix.exs.

checkout did not place the project where expected

A sparse or path-scoped checkout, or a build matrix pointing at the wrong directory, leaves mix.exs outside the current directory.

How to fix it

Set working-directory to the project root

  1. Locate the folder that contains mix.exs.
  2. Set working-directory (or a defaults block) to that folder for the mix steps.
  3. Re-run so mix loads the project.
.github/workflows/ci.yml
- name: Test
  working-directory: apps/my_app
  run: mix test

Use defaults for all steps in the job

Set a job-level default so every run step starts in the app directory.

.github/workflows/ci.yml
defaults:
  run:
    working-directory: apps/my_app

How to prevent it

  • Pin working-directory for mix steps in subfolder/umbrella repos.
  • Verify actions/checkout lands the project where the job expects it.
  • Echo pwd and ls mix.exs early when debugging path issues.

Frequently asked questions

What causes ""Could not find a Mix.Project""?
The Elixir project lives in a subfolder (a monorepo, or an umbrella child), but the step runs from the repo root where there is no mix.exs.
How do I fix "Could not find a Mix.Project"?
Set working-directory to the project root

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card