Changing elixir version in mix.exs

I have updated the globally installed Elixir version to 1.11.0.

Erlang/OTP 23 [erts-11.1.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe] [dtrace]

Elixir 1.11.0 (compiled with Erlang/OTP 23)

When coming back to an old project and trying to run mix setup, it failed with:

All dependencies are up to date
** (Mix) You're trying to run :my_app on Elixir v1.11.0 but it has declared in its mix.exs file it supports only Elixir ~> 1.10.2

I tried just to modify Elixir version in mix.exs file to the latest one:

  def project do
    [
      app: :my_app,
      version: "0.1.0",
      elixir: "~> 1.11.0",
      elixirc_paths: elixirc_paths(Mix.env()),
      compilers: [:phoenix, :gettext] ++ Mix.compilers(),
      start_permanent: Mix.env() == :prod,
      aliases: aliases(),
      deps: deps()
    ]
  end

but it didn’t fix the issue. Removing the mix.lock file didn’t help either.
Why so and what is the right way to upgrade the elixir version of a project?
In Ruby, JS projects it works without any problem.

Thank you.

Hmm, the app started with mix phx.server with no errors.
I think it is rather VS Code errors:

an exception was raised:
    ** (MatchError) no match of right hand side value: {:error, {:hex, {'no such file or directory', 'hex.app'}}}
        lib/hex.ex:7: Hex.start/0
        (mix 1.11.0) lib/mix/hex.ex:59: Mix.Hex.start/0
        (mix 1.11.0) lib/mix/dep/loader.ex:194: Mix.Dep.Loader.with_scm_and_app/4
        (mix 1.11.0) lib/mix/dep/loader.ex:147: Mix.Dep.Loader.to_dep/3
        (elixir 1.11.0) lib/enum.ex:1399: Enum."-map/2-lists^map/1-0-"/2
        (mix 1.11.0) lib/mix/dep/loader.ex:364: Mix.Dep.Loader.mix_children/2
        (mix 1.11.0) lib/mix/dep/loader.ex:18: Mix.Dep.Loader.children/0
        (mix 1.11.0) lib/mix/dep/converger.ex:57: Mix.Dep.Converger.all/4ElixirLS

Yep, it was that. I had to remove .elixir_ls folder of the project (generated by the ElixirLS extension of VS Code), close the project folder in VS Code and quit.
After re-opening the same project, the errors related to the ElixirLS extension have gone.

It’s [almost] always wiser to stick to the minor version, not to the patch:

elixir: "~> 1.10",
elixir: "~> 1.11",

That would make the minor update to go smoothly.

2 Likes

vs_code is painful when dealing with dependencies, so painful I close it as well when I do upgrade.