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
2018-11-23_16:31:25.224591590
2018-11-23_15:31:25.373837652
2018-11-23_16:31:25.452186325
> date +%F_%X.%N; ./docker-exec date  +%F_%X.%N; date  +%F_%X.%N
2018-11-23_16:31:27.045086031
2018-11-23_15:31:27.220337493
2018-11-23_16:31:27.297787468
> date +%F_%X.%N; ./docker-exec date  +%F_%X.%N; date  +%F_%X.%N
2018-11-23_16:31:28.657464324
2018-11-23_15:31:28.812484845
2018-11-23_16:31:28.890919434
> date +%F_%X.%N; ./docker-exec date  +%F_%X.%N; date  +%F_%X.%N
2018-11-23_16:31:30.718951179
2018-11-23_15:31:30.891650122
2018-11-23_16:31:30.940783413
> date +%F_%X.%N; ./docker-exec date  +%F_%X.%N; date  +%F_%X.%N
2018-11-23_16:31:32.732510617
2018-11-23_15:31:32.911098272
2018-11-23_16:31:32.989577565
> date +%F_%X.%N; ./docker-exec date  +%F_%X.%N; date  +%F_%X.%N
2018-11-23_16:31:33.852015333
2018-11-23_15:31:33.980827196
2018-11-23_16:31:34.060757482

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

2 Likes

Oops, I overlooked the hour!

Thanks.

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

http://erlang.org/doc/apps/erts/time_correction.html#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. https://github.com/elixir-lang/elixir/issues/8450

1 Like