Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

mix do [...], compile does not seem to fully compile application #10712

Closed
mitchellhenke opened this issue Feb 14, 2021 · 2 comments
Closed

mix do [...], compile does not seem to fully compile application #10712

mitchellhenke opened this issue Feb 14, 2021 · 2 comments

Comments

@mitchellhenke
Copy link
Contributor

Sorry for the title, not sure how to best describe this 馃槵

Environment

  • Elixir & Erlang/OTP versions (elixir --version):

Erlang/OTP 23 [erts-11.1.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe] [dtrace]

Elixir 1.11.2 (compiled with Erlang/OTP 23)

  • Operating system: macOS 10.15.7

Current behavior

The behavior was originally noticed in getsentry/sentry-elixir#451. It's related to some Sentry code that does some rather twisted things to store source code, but the behavior seems to be reproducible outside of that context.

When running compile in a list of mix do tasks, the application still recompiles even if compile is the final task in the list. Steps to reproduce:

$ mix phx.new phoenix_compile_recompile --no-webpack
# ...
$ mix deps.compile
# ...
$ mix do compile, deps.compile phoenix --force, compile
==> phoenix
Compiling 66 files (.ex)
Generated phoenix app

$ mix compile
Compiling 14 files (.ex)
Generated phoenix_compile_recompile app

Expected behavior

I would expect for there to be nothing left to recompile when running the final mix compile, but the Phoenix project still recompiles some files.

This is a very unlikely case to hit in the normal course of things, but I wasn't sure if this was expected behavior.

@josevalim
Copy link
Member

This is by design. When you run a task, it is marked as ran, and it won't run again. That's because we don't want to run compile (or check the file system to see if we need to compile) every time you invoke the compile task, because often tasks are recursive. For example, take the alias setup in Phoenix apps. It will create the db, run migrations, etc. All of those require the code to be compiled. So we want to compile once and then the task is marked as ran until the end of that command.

I will add a note to the docs.

@mitchellhenke
Copy link
Contributor Author

Makes total sense, thanks for the explanation!

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

No branches or pull requests

2 participants