Fresh Phoenix install results in "** (MatchError) no match of right hand side value: :error"

Hi all,

I’m just trying to get up and running with Phoenix and Elixir… Exciting times!

However, I’m unsure what I’m doing here. I’ve followed the Up and Running guide, but when I do the initial cd hello & mix deps.get I get the following trace:

* Updating heroicons (https://github.com/tailwindlabs/heroicons.git - v2.1.1)
remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Resolving Hex dependencies...
** (MatchError) no match of right hand side value: :error
    (hex 2.1.1) lib/hex/solver/package_lister.ex:47: anonymous fn/4 in Hex.Solver.PackageLister.dependencies_as_incompatibilities/4
    (elixir 1.17.2) lib/enum.ex:1703: Enum."-map/2-lists^map/1-1-"/2
    (elixir 1.17.2) lib/enum.ex:1703: Enum."-map/2-lists^map/1-1-"/2
    (hex 2.1.1) lib/hex/solver/package_lister.ex:46: Hex.Solver.PackageLister.dependencies_as_incompatibilities/4
    (hex 2.1.1) lib/hex/solver/solver.ex:123: Hex.Solver.Solver.choose_package_version/1
    (hex 2.1.1) lib/hex/solver/solver.ex:25: Hex.Solver.Solver.solve/2
    (hex 2.1.1) lib/hex/solver.ex:64: Hex.Solver.run/5
    (hex 2.1.1) lib/hex/remote_converger.ex:69: Hex.RemoteConverger.run_solver/5

I’ve done a little bit of preliminary trial-and-error testing on deps, and it seems to occur when I have any of the following deps in the mix.exs

      {:phoenix_ecto, "~> 4.5"},
      {:ecto_sql, "~> 3.10"},
      {:postgrex, ">= 0.0.0"},

If I comment these dependencies out, mix deps.get works happily.

Any pointers as to where I might be going wrong? This is literally a clean installation.

Using the following versions:

Erlang/OTP 26 [erts-14.2.5] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit] [dtrace]

Elixir 1.17.2 (compiled with Erlang/OTP 26)

~ P

Welcome @pobk! Your error is quite unexpected. I did this and it all worked:

$ mix local.hex
$ mix archive.install hex phx_new
$ mix phx.new demo

I am using the same Erlang and Elixir versions as you.

Can you try the above? If the error persists can you post your mix.exs+mix.lock files here?

Hi @josevalim,

This error is indeed unexpected. I have spun up a few different instances of late, just trying new things on clean projects… It has worked for me previously, hence why I’m wondering if there’s something I’ve done wrong somewhere.

I tried those commands, but received the same error…

➜  projects mkdir test
➜  projects cd test
➜  test
➜  test
➜  test
➜  test mix local.hex
Found existing entry: /Users/richard/.mix/archives/hex-2.1.1
Are you sure you want to replace it with "https://builds.hex.pm/installs/1.16.0/hex-2.1.1.ez"? [Yn] y
* creating /Users/richard/.mix/archives/hex-2.1.1
➜  test mix archive.install hex phx_new
Resolving Hex dependencies...
Resolution completed in 0.013s
New:
  phx_new 1.7.14
* Getting phx_new (Hex package)
All dependencies are up to date
Compiling 11 files (.ex)
Generated phx_new app
Generated archive "phx_new-1.7.14.ez" with MIX_ENV=prod
Found existing entry: /Users/richard/.mix/archives/phx_new-1.7.14
Are you sure you want to replace it with "phx_new-1.7.14.ez"? [Yn] y
* creating /Users/richard/.mix/archives/phx_new-1.7.14
➜  test mix phx.new demo
* creating demo/lib/demo/application.ex
* creating demo/lib/demo.ex
* creating demo/lib/demo_web/controllers/error_json.ex
{... snip ...}
* creating demo/assets/tailwind.config.js

Fetch and install dependencies? [Yn]
* running mix deps.get

We are almost there! The following steps are missing:

    $ cd demo
    $ mix deps.get

Then configure your database in config/dev.exs and run:

    $ mix ecto.create

Start your Phoenix app with:

    $ mix phx.server

You can also run your app inside IEx (Interactive Elixir) as:

    $ iex -S mix phx.server

➜  test cd demo
➜  demo mix deps.get
* Updating heroicons (https://github.com/tailwindlabs/heroicons.git - v2.1.1)
remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Resolving Hex dependencies...
** (MatchError) no match of right hand side value: :error
    (hex 2.1.1) lib/hex/solver/package_lister.ex:47: anonymous fn/4 in Hex.Solver.PackageLister.dependencies_as_incompatibilities/4
    (elixir 1.17.2) lib/enum.ex:1703: Enum."-map/2-lists^map/1-1-"/2
    (elixir 1.17.2) lib/enum.ex:1703: Enum."-map/2-lists^map/1-1-"/2
    (hex 2.1.1) lib/hex/solver/package_lister.ex:46: Hex.Solver.PackageLister.dependencies_as_incompatibilities/4
    (hex 2.1.1) lib/hex/solver/solver.ex:123: Hex.Solver.Solver.choose_package_version/1
    (hex 2.1.1) lib/hex/solver/solver.ex:25: Hex.Solver.Solver.solve/2
    (hex 2.1.1) lib/hex/solver.ex:64: Hex.Solver.run/5
    (hex 2.1.1) lib/hex/remote_converger.ex:69: Hex.RemoteConverger.run_solver/5
➜  demo cat mix.exs
defmodule Demo.MixProject do
  use Mix.Project

  def project do
    [
      app: :demo,
      version: "0.1.0",
      elixir: "~> 1.14",
      elixirc_paths: elixirc_paths(Mix.env()),
      start_permanent: Mix.env() == :prod,
      aliases: aliases(),
      deps: deps()
    ]
  end

  # Configuration for the OTP application.
  #
  # Type `mix help compile.app` for more information.
  def application do
    [
      mod: {Demo.Application, []},
      extra_applications: [:logger, :runtime_tools]
    ]
  end

  # Specifies which paths to compile per environment.
  defp elixirc_paths(:test), do: ["lib", "test/support"]
  defp elixirc_paths(_), do: ["lib"]

  # Specifies your project dependencies.
  #
  # Type `mix help deps` for examples and options.
  defp deps do
    [
      {:phoenix, "~> 1.7.14"},
      {:phoenix_ecto, "~> 4.5"},
      {:ecto_sql, "~> 3.10"},
      {:postgrex, ">= 0.0.0"},
      {:phoenix_html, "~> 4.1"},
      {:phoenix_live_reload, "~> 1.2", only: :dev},
      # TODO bump on release to {:phoenix_live_view, "~> 1.0.0"},
      {:phoenix_live_view, "~> 1.0.0-rc.1", override: true},
      {:floki, ">= 0.30.0", only: :test},
      {:phoenix_live_dashboard, "~> 0.8.3"},
      {:esbuild, "~> 0.8", runtime: Mix.env() == :dev},
      {:tailwind, "~> 0.2", runtime: Mix.env() == :dev},
      {:heroicons,
       github: "tailwindlabs/heroicons",
       tag: "v2.1.1",
       sparse: "optimized",
       app: false,
       compile: false,
       depth: 1},
      {:swoosh, "~> 1.5"},
      {:finch, "~> 0.13"},
      {:telemetry_metrics, "~> 1.0"},
      {:telemetry_poller, "~> 1.0"},
      {:gettext, "~> 0.20"},
      {:jason, "~> 1.2"},
      {:dns_cluster, "~> 0.1.1"},
      {:bandit, "~> 1.5"}
    ]
  end

  # Aliases are shortcuts or tasks specific to the current project.
  # For example, to install project dependencies and perform other setup tasks, run:
  #
  #     $ mix setup
  #
  # See the documentation for `Mix` for more info on aliases.
  defp aliases do
    [
      setup: ["deps.get", "ecto.setup", "assets.setup", "assets.build"],
      "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
      "ecto.reset": ["ecto.drop", "ecto.setup"],
      test: ["ecto.create --quiet", "ecto.migrate --quiet", "test"],
      "assets.setup": ["tailwind.install --if-missing", "esbuild.install --if-missing"],
      "assets.build": ["tailwind demo", "esbuild demo"],
      "assets.deploy": [
        "tailwind demo --minify",
        "esbuild demo --minify",
        "phx.digest"
      ]
    ]
  end
end

I don’t yet have a mix.lock file for this… this error happens during the initial mix deps.get.

~ P

Perhaps try what’s suggested in this comment, i.e.:

mv ~/.hex/cache.ets ~/.hex/cache-backup.ets

to see if it’s not a problem with Hex cache (run mix deps.get after this).

3 Likes

Hi @katafrakt,

Thanks for that!

That’s worked! Huzzah!

~ P

1 Like

Yet another case of “when in doubt, clear caches”.