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) Could not find a Mix.Project, please ensure you are running Mix in a
directory with a mix.exs fileCommon 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
- Locate the folder that contains
mix.exs. - Set
working-directory(or a defaults block) to that folder for the mix steps. - Re-run so mix loads the project.
- name: Test
working-directory: apps/my_app
run: mix testUse defaults for all steps in the job
Set a job-level default so every run step starts in the app directory.
defaults:
run:
working-directory: apps/my_appHow 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
pwdandls mix.exsearly when debugging path issues.