`mix`: I keep having a `Version.InvalidRequirementError` wherever I call it, even without a `mix.exs` file

Hi everyone,

I have a Ubuntu server (on 5.15.0-57-generic) running a Phoenix website.

Recently I tried to update hex with mix local.hex, but the update process got interrupted because I didn’t have enough disk space. Since then, every time I type a mix command, I keep having the following error:

** (Version.InvalidRequirementError) invalid requirement: ""
    (elixir 1.14.1) lib/version.ex:441: Version.parse_requirement!/1
    (elixir 1.14.1) lib/version.ex:287: Version.match?/3
    (mix 1.14.1) lib/mix/local.ex:122: Mix.Local.check_elixir_version_in_ebin/1
    (mix 1.14.1) lib/mix/local.ex:41: anonymous fn/2 in Mix.Local.append_archives/0
    (elixir 1.14.1) lib/enum.ex:2468: Enum."-reduce/3-lists^foldl/2-0-"/3
    (mix 1.14.1) lib/mix/local.ex:40: Mix.Local.append_archives/0
    (mix 1.14.1) lib/mix/cli.ex:8: Mix.CLI.main/1

This happens whether there is a mix.exs file in the current directory or not. iex, elixir and elixirc binaries all work fine.

My ~/.mix/archives/hex-2.0.1 was deleted during the failed update. I tried to reinstall or replace the directory with a fresh one, but couldn’t get mix to work. Of course mix local.hex gives the same error as above.

elixir -v gives:

Erlang/OTP 25 [erts-13.1.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [jit:ns]

Elixir 1.14.1 (compiled with Erlang/OTP 25)

How can I get mix to work again?

1 Like

Do you have other directories or files in ~/.mix/archives/? If so delete them.

2 Likes

Ok, this works, thank you so much :slight_smile:
so my ~/.mix/archives/2.0.6 directory was corrupt then? Do you know why the error wasn’t mentioning the file and showing an empty requirement?