zekedou

zekedou

Warning: mtime was set to the future - triggered by two rapid successive calls to Elixir compiler (possible bug - need your help to test)

Although parts of the following describe behavior observed in Phoenix, this is not a Phoenix bug (I’ll explain why later). It appears to be an Elixir bug, so I’m posting this in the “Elixir” category.

The possible bug

Recently, I encountered the following warning while developing a Phoenix application:

warning: mtime (modified time) for "lib/demo_web/controllers/page_html.ex" was set to the future, resetting to now

Have any of you encountered this issue? I haven’t seen any similar reports in the community.

To reproduce it:

  1. Create an app: mix phx.new demo --no-ecto --no-live --no-tailwind
  2. Enter the dev environment: cd demo && iex -S mix phx.server
  3. Visit http://localhost:4000 in your browser and keep the tab open (this is necessary, as it triggers the edge case)
  4. Modify demo/lib/demo_web/controllers/page_html/home.html.heex and save
  5. The warning should appear in your IEx. If not, repeat step 4 a few more times.

The chain of logic leading to the warning:

  1. We modify demo/lib/demo_web/controllers/page_html/home.html.heex.
  2. Phoenix.LiveReloader detects the change and pushes an event to the browser.
  3. The browser requests / to refresh, triggering Phoenix.CodeReloader to reload the code.
  4. The refreshed page requests /phoenix/live_reload/socket to re-establish live reloading, triggering Phoenix.CodeReloader to reload the code again.

I suspect the warning is caused by two rapid successive calls to Phoenix.CodeReloader.reload/2, which in turn calls mix compile.elixir. To verify this, I created a minimal reproduction: GitHub - plastic-gun/elixir-compile-warning-1 · GitHub — and indeed, the warning reproduced.

I need help testing whether this is consistently reproducible across platforms and elixir versions. So far I’ve only tested on macOS — it would be great if those on Linux and Windows could test as well.

If this does turn out to be a bug, we’ll have already collected the necessary environment information.

How to help?

Run the project at GitHub - plastic-gun/elixir-compile-warning-1 · GitHub and report your results in the following format:

Reproduced?: Y/N
OS: <like macOS 15.7.5>
Erlang and Elixir:
<output of `elixir --version`>

Marked As Solved

josevalim

josevalim

Creator of Elixir

Fixed in main as part of the issue you opened. They both had the same root cause. Please give main a try and let me know how it goes!

Thank you for all reports! Also please double check we haven’t reintroduced View modules are not recompiled after triggering compilation error of unmatched tag in template files. · Issue #6476 · phoenixframework/phoenix · GitHub. :heart:

Also Liked

gtcode

gtcode

Reproduced: Y
OS: Ubuntu 24.04.3 LTS
Erlang and Elixir:
Erlang/OTP 28 [erts-16.2] [source] [64-bit] [smp:24:24] [ds:24:24:10] [async-threads:1] [jit:ns]

Elixir 1.19.5 (compiled with Erlang/OTP 28)
zekedou

zekedou

All the issues have been checked again:

  • Elixir issue #15277 has been fixed.
  • Elixir issue (mentioned here) has been fixed.
  • Phoenix issue #6476 has been fixed.

Thanks! @josevalim @gtcode

Where Next?

Popular in Questions Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lists...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New

Other popular topics Top

danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29603 241
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31013 112
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31265 143
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement