How to fix Rebar3: detected a lock file from a newer version
I added `hackney` to an Elixir project. Then `mix deps.compile` printed this warning:
> ===> Rebar3 detected a lock file from a newer version. It will be loaded in compatibility mode, but important information may be missing or lost. It is recommended to upgrade Rebar3.
Mix uses its own local copy of Rebar3 to build Erlang dependencies such as `hackney`. The dependency ships a `rebar.lock` file that a newer Rebar3 wrote, so the old local copy cannot read all of it.
The fix is to update the Rebar3 that Mix uses:
```bash
mix local.rebar --force
```
`--force` installs it without a prompt. Then clean and compile the dependency again:
```bash
mix deps.clean hackney --build
mix deps.compile
```
If the warning comes back, check that your Elixir and Erlang/OTP versions are recent. Old versions of Mix can install only old versions of Rebar3.
Nick Ciolpan
06 Jul 2020
« Back to post