How can I create a new Phoenix project using the latest 1.6.0-dev version?

Viewed 996

I would like to try out the new phx.gen.auth and esbuild systems. I know 1.6.0-dev is not released yet but on Twitter people are talking about how good it is.

I can't seem to find a way to create a new app using this unreleased version.

2 Answers

You can tell mix to install the Phoenix 1.6 release candidate like so:

$ mix archive.install hex phx_new 1.6.0-rc.0

If you don't supply the release candidate (rc.0) then mix will tell you the closest match which may be a good idea as new release candidates could be released.

$ mix archive.install hex phx_new 1.6.0

** (Mix) No matching version for phx_new 1.6.0 (from: mix.exs) in registry

While there is no package matching the requirement above, there are pre-releases available:

  * 1.6.0-rc.0

I just did this today, here are the steps I took.

clone phoenix 1.6 down locally somewhere and install the deps:

git@github.com:phoenixframework/phoenix.git
cd phoenix
mix deps.get

Then you want to read the installer README here https://github.com/phoenixframework/phoenix/tree/master/installer which tells you to uninstall your current phoenix installer:

mix archive.uninstall phx_new

and then build and install a new one from the current source:

cd installer
MIX_ENV=prod mix do archive.build, archive.install

Now you can use mix phx.new in another folder to generate a new phoenix app using the latest master that you just cloned.

NOTE: the generated phoenix project is going to have a line in mix.exs pointing to the latest phoenix on github:

defp deps do
  [
    {:phoenix, github: "phoenixframework/phoenix", override: true},
    ...
  ]
end

This will obviously change as new commits are added, but you can point to you local by changing it to a path based dep if you want:

defp deps do
  [
    {:phoenix, path: "../phoenix", override: true},
    ...
  ]
end

The reason you might want to do this (like I did) is because you want to include some un-merged PRs or try tweaking some things locally yourself. For example, running mix phx.gen.auth is going to use the mix task from the defined phoenix dependency in your mix file, NOT the mix task that was present at the time of you building the installer.

Related