Use a previous version of phoenix liveview generator?

I have a project on Phoenix 1.7.12 and was able to use live view generators (I am pretty sure :slight_smile: ). I created a new project with a newer version of Phoenix and Elixir for testing, then switched back to the old project and now I’m seeing:

>mix phx.gen.live ...
** (RuntimeError) Mix.Tasks.Phx.Gen.Live requires :phoenix_live_view >= 1.0.0, got: 0.20.17
    (phoenix 1.7.18) lib/mix/phoenix.ex:376: Mix.Phoenix.ensure_live_view_compat!/1
    (phoenix 1.7.18) lib/mix/tasks/phx.gen.live.ex:110: Mix.Tasks.Phx.Gen.Live.run/1
    (mix 1.16.3) lib/mix/task.ex:478: anonymous fn/3 in Mix.Task.run_task/5
    (mix 1.16.3) lib/mix/cli.ex:96: Mix.CLI.run_task/2

The above is using the 1.7.18 generators. I’ve tried to uninstall and reinstall the Phoenix archive to the 1.7.2 version and that didn’t seem to work at all. My deps are pretty much stock.

      {:phoenix, "~> 1.7.12"},
      {:phoenix_ecto, "~> 4.4"},
      {:ecto_sql, "~> 3.10"},
      {:postgrex, ">= 0.0.0"},
      {:phoenix_html, "~> 4.0"},
      {:phoenix_live_reload, "~> 1.2", only: :dev},
      {:phoenix_live_view, "~> 0.20.2"},
      {:floki, ">= 0.30.0", only: :test},
      {:phoenix_live_dashboard, "~> 0.8.3"},
      {:esbuild, "~> 08", 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.2"}

Could it be that I was mistaken and I had never been able to use LiveView generators on the older project :thinking:

1 Like

I have also attempted to create a new phoenix project with the older version, and the Application.spec(:phoenix, :vsn) in that returns 1.7.18.

mix deps.compile ?

edit: alternatively mix archive.install hex phx_new 1.7.12

The phx_new archive includes only the generator for the phx.new command. All other generators are part of phoenix itself, so downgrading it should get you back to the previous generators.

{:phoenix, "~> 1.7.12"} however doesn’t resolve to 1.7.12, but to everything >= 1.7.12 and < 1.8.0. You’d need == 1.7.12 to get exactly that version.

3 Likes

Tried both of those no dice.

I will try this one later today, but I did not update the deps on the older project. If I switched projects I would not expect one to use the generators of a different version.

I have the exact same issue. I use Elixir with asdf
and use the following versions in my .tool-versions

elixir 1.16.3-otp-26
erlang 26.2.5.2
nodejs 21.7.3

Just change your deps for :phoenix_live_view

 defp deps,
    do: [
      {:phoenix_live_view, "~> 1.0.0"},

I don’t believe I am able to upgrade at this time sadly.