Skip to content

Conversation

@matthewsinclair
Copy link

@matthewsinclair matthewsinclair commented Oct 23, 2025

Running mix format at umbrella root crashes with a MatchError in Mix.ProjectStack.

The Problem

The fix for #228 (commits 9eddbeb and 0d1048a) added compilation before formatting
to ensure modules are available. This breaks umbrella projects because calling
Mix.Task.run("compile") from within a formatter plugin triggers recursive
compilation, violating Mix.ProjectStack's expectations.

Changes

  • Added safe_compile/0 that checks Mix.Project.umbrella?() before compiling
  • Skips compilation at umbrella root, runs normally elsewhere
  • Added graceful error handling when modules can't be loaded
  • Improved error messages in the mix task for umbrella users
  • Added test coverage

Fixes #231

Skips compilation at umbrella root to avoid Mix.ProjectStack violations.
The compile task added in 9eddbeb (fixing ash-project#228) causes crashes in umbrella
projects because Mix.ProjectStack doesn't support recursive compilation
during format operations.
@zachdaniel
Copy link
Contributor

I've added some more logic here, mind pulling and updating? Thank you for the fix 🙇

@matthewsinclair
Copy link
Author

Thanks, Zach. LGTM for the merge.

@zachdaniel
Copy link
Contributor

Not sure if I messed it up again but there are still conflicts 😢

@matthewsinclair
Copy link
Author

matthewsinclair commented Oct 26, 2025

Not sure what the issue is? When I run the tests on my side on the PR branch in my fork, I get clean tests:

$ git status
On branch fix/umbrella-format-crash
Your branch is up to date with 'origin/fix/umbrella-format-crash'.

nothing to commit, working tree clean
$ mix test
Generated spark app
Running ExUnit with seed: 815428, max_cases: 32

..................................................................................................
Finished in 3.6 seconds (0.4s async, 3.1s sync)
5 doctests, 93 tests, 0 failures

What conflicts are you seeing? Or are you referring to the merge conflict below on lib/spark/formatter.ex?

Let me see if I can fix it on my side ... ok, should be good go now.

Resolved conflict in lib/spark/formatter.ex by updating safe_compile()
to include the loadpaths tasks from main (v2.3.11) while preserving
the umbrella project safety check.

This combines:
- The umbrella crash fix (skips compilation in umbrella projects)
- The loadpaths fix from v2.3.11
@zachdaniel
Copy link
Contributor

Please fix credo then I'll merge 🙇

@matthewsinclair
Copy link
Author

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mix format crashes at umbrella root with MatchError

2 participants