Time warps and Nerves

If you’re using Nerves, please take a moment to review if you need to enable time warp support on your system. If you’re using a library that handles time, you may run into an issue where the System.os_time/1 is right but System.system_time/1 is still in the 1970s. This is confusing since it can happen deep in the Ecto SQLite adapter, for example.

The good news is that a lot of thought about time handling has gone into the Erlang VM. The issue is that Nerves devices (using nerves_time) update their clocks from 1970 to the current time after the Erlang VM has started. This is a time warp and the default is to not allow it for Erlang system time. The time warp modes documentation describes the options.

The OTP Team’s recommendation is to enable the multi_time_warp mode and we’re updating the Nerves new project generator to enable it by default. However, that’s not going to change existing projects. To enable it in your project, add the following to the beginning or middle of your vm.args:

+C multi_time_warp

Huge thanks to Brian May for identifying the issue.

14 Likes