Annoying mtime changing: "mtime for ... was set to the future, resetting to now"

Hello everyone,

I am seeing this message quite often:

warning: mtime (modified time) for "/app/_build/dev/lib/my_app/.mix/compile.elixir" was set to the future, resetting to now

Regularly, this affects source files as well. The resulting problem is, that my editor (vim) thinks the file has changed, which is quite annoying.

My elixir application runs locally inside a docker container, my editor runs on the host. It looks like they disagree on time!

Is anybody else having this problem? How can I find out what is causing this? (I have already found the error message in the elixir source code).

1 Like

Check the time on both your host and in the container, I guess. Then maybe setup ntp service in the container.

It doesn’t look like there is a significant difference:

> date +%F_%X.%N; ./docker-exec date  +%F_%X.%N; date  +%F_%X.%N
> date +%F_%X.%N; ./docker-exec date  +%F_%X.%N; date  +%F_%X.%N
> date +%F_%X.%N; ./docker-exec date  +%F_%X.%N; date  +%F_%X.%N
> date +%F_%X.%N; ./docker-exec date  +%F_%X.%N; date  +%F_%X.%N
> date +%F_%X.%N; ./docker-exec date  +%F_%X.%N; date  +%F_%X.%N
> date +%F_%X.%N; ./docker-exec date  +%F_%X.%N; date  +%F_%X.%N

One hour is a pretty big difference for me … But it seems the problem might be with an incorrectly set timezone.


Oops, I overlooked the hour!


Time skew between hosts and containers shared filesystem is quite normal, you can’t do anything about that. The easiest thing is to compile on the host and not to use the container at all.

I’m certainly not switching back to developing on the host. I’ve seen many cumulative hours wasted due to “errors” coming from differences in host environments.

I have set the TZ environment variable in my development container, but it looks like the problem still exists. The date commands inside and outside show the same time and date, however.

1 Like

It’s happening for files my editor should not have touched at all, including things like “/app/_build/dev/lib/my_app/.mix/compile.elixir”. Something is fishy here…

How can I find out which other process is changing the mtime?

The date command and System.system_time are in disagreement:

iex(phx@d696ae906347)16> {System.cmd("date", ["+%s"]), System.system_time(:second)}
{{"1543234866\n", 0}, 1543193441}

The latter is used by elixir for comparing source posix modification times to the current time.

date is OS date. System.system_time is calling erlang:system_time which Returns current Erlang system time

That’s where the difference comes from.

Aaah that makes sense. My VM time is significantly skewed because I suspend my laptop.

I think I should open an issue.

Opening an issue sounds good, and the multi_time_warp option referred to in the documentation above may fix your problem for now. You can try starting your app with --erl "+C multi_time_warp" in the mix or iex arguments.

1 Like

I’m a bit afraid of doing that as it could break production/dev parity…

It’s not a bad idea to use that setting in production too if your code is time-warp safe :slight_smile:

1 Like

I am having the same issue here. Have you managed to solve it? How?

It’s fixed in Elixir 1.8.

1 Like