Updating dependency to use new phoenix version

I need a suggestion here. So I have a phoenix project which is using this version

{:phoenix, “~> 1.4.10”}

and I want to update this to phoenix’s latest version. But the project is not on production but we are going to put this on production. Project is heavily using LiveView and it’s compiled with this version

{:phoenix_live_view, “~> 0.7.1”, override: true}

So already all the build file is compiled with this version. What steps should I take before updating to newer version and compiling a new build?
Also, how do I this carefully?

Hi,

I would do the following,

Update the dependencies in mix.exs to the latest versions.
Run mix deps.get
Go to the assets folders
Run npm install --force phoenix_live_view

When I am in doubt I delete the _build folder and then, run mix deps.unlock --allbefore, this is riskier because you will be updating all the packages. But generally I have had no problems.

Sometimes I create a totally new app to check which package versions it uses, in this case you could run mix phx.new my_new_project --live

1 Like

So I do not delete the build file before I’m trying to update all the deps right?

You can leave the _build folder as is or delete it, it is not dangerous, it will be created again in the next compile.

Unlocking the dependencies with mix deps.unlock --all will update all the dependencies to their new versions as specified in mix.exs. Which in some uncommon cases could give you problems.

If you are unsure, make a copy of your entire folder and try to upgrade the copy. It should work.

But should I change this also in mix.exs file

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

Currently in my project elixir is 1.5 here

A simple way is to create a new Phoenix project and copy the new configuration (You need to take care of application name).

In particular config, and your_app_web.ex file.

But there have been a lot of change in liveview API since version 0.7.

A lot… You might have to check if it still works with newer version.

I installed all the latest deps and compiled it again. But now the api are breaking down even the sign in and sign up part is not working. :sweat_smile:

You can leave it as is,

Means 1.7 or greater. But you should check if you have at least 1.7 installed. If it is not, upgrade it. I have never had problems with new elixir versions.

1 Like

Yes, version 0.7 was in high development mode, and now the API has changed.

But doing something like…

mix phx.new --live koko
cd koko
mix ecto.create
mix phx.gen.live Accounts User users name:string age:integer

…and exploring code helped me to see what has changed, reading the doc too helped me :slight_smile:

The way to create live link is different.

1 Like

Actually it’s not the LiveView API which has stopped. I’m talking about Project API’s. When I shifted to new version of phoenix which is 1.5.4 now. So whatever routes I have defined in my router somehow it’s not able to find that routes. Maybe I need to compare the both version and check what has changed till now.