Hex version - ** (Mix) The task "phx.new" could not be found

I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could not be found. After googling I understood that the problem is with Hex version. I have other phoenix projects running in previous elixir versions, soon if I update Hex using mix local.hex, will that affect all my other projects also?

4 Likes

You need to install archive first:

mix archive install hex phx_new
5 Likes

This means that you did not install the phx_new archive. What command did you use to install it and what was the result of it?

What is your complete output when running mix archive?

2 Likes

But I already have other Phoenix projects running in my system. Does that not mean that I have installed the phx_new archive?

mix archive shows this

* hex-0.19.0
* phx_new
Archives installed at: /Users/sk/.asdf/installs/elixir/1.6.6/.mix/archives

You don’t need the archive to run phoenix, it’s sole purpose is just to setup an initial new project scaffolding (that you can still otherwise do manually).

Seems like you have it, what is the entire and complete output of mix phx.new?

Also you really need to update hex, I’m surprised the system hasn’t asked you to yet. Run mix.local.hex.

Also whoa, that’s quite a bit old, you really should update elixir (and OTP) too. o.O
Elixir is up to 1.9.1 and OTP is up to 22.1. It’s generally go to stay within 2 or 3 versions of recent as a few big libraries tend to not work before that.

1 Like

I know I have to upgrade the elixir and OTP versions, but we are in the middle of something and are waiting for that to be done to upgrade everything.

If I run mix.local.hex then will that affect my other projects, which as you know, are using very old versions.!:neutral_face:

No, it’s supposed to always be updated, it’s the interface to the hex server, if it’s not updated then it might not work at all, so if anything it would take it from non-working to working. :slight_smile:

2 Likes

ok, thanks a lot :slightly_smiling_face:
Will upgrade everything to the latest versions soon.!

1 Like

even after upgrading hex mix phx.new still throws ** (Mix) The task "phx.new" could not be found.
Now mix archive gives

* hex-0.20.1
Archives installed at: /Users/sk/.asdf/installs/elixir/1.9.1/.mix/archives

Also I installed phx_new

You installed a new asdf prefix, each has it’s own archives and all so run mix archive install hex phx_new again as your mix archive command didn’t have it. Make sure to run everything in the same asdf prefix.

mix archive.install hex phx_new 1.4.8 this installed the latest version

2 Likes

I think 1.4.10 is actually latest, that command would choose the older 1.4.8. :slight_smile:

Oh ok, my bad :sweat_smile:

1 Like

Correct command is:

mix archive.install hex phx_new

Or:

mix archive.install hex phx_new VERSION
29 Likes

mix archive.install hex phx_new

This worked for me.

Thanks @qasimsina

11 Likes

yes this worked.

2 Likes