Installing phoenix in asdf-elixir

It fixed Erlang / Elixir, but I couldnt install correctly Phoenix.
Did you succeed?
Some of my deps like apartmentex that depends on ecto can’t compile.

I did try normal url and local file to install Phoenix.
Erlang, Nodejs & Elixir last versions from ASDF. (including that PR)

Mac OS High Sierra last beta.

What command do you use to install Phoenix and what error messages do you get? What are your erlang and elixir versions?

Erlang 20 with RP.
Elixir 1.5.1.

Remote
mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez
Are you sure you want to replace it with “https://github.com/phoenixframework/archives/raw/master/phx_new.ez”? [Yn] Y
* creating .asdf/installs/elixir/1.5.1/.mix/archives/phx_new

ls .asdf/installs/elixir/1.5.1/.mix/archives/phx_new/phx_new/ebin/
Elixir.Mix.Tasks.Local.Phoenix.beam Elixir.Phx.New.Generator.beam
Elixir.Mix.Tasks.Local.Phx.beam Elixir.Phx.New.Project.beam
Elixir.Mix.Tasks.Phoenix.New.beam Elixir.Phx.New.Single.beam
Elixir.Mix.Tasks.Phx.New.Ecto.beam Elixir.Phx.New.Umbrella.beam
Elixir.Mix.Tasks.Phx.New.Web.beam Elixir.Phx.New.Web.beam
Elixir.Mix.Tasks.Phx.New.beam phx_new.app
Elixir.Phx.New.Ecto.beam

Local
mix archive.install ~/phx_new.ez

No mix phoenix tasks populated in mix help.

1 Like

I do hope you mean mix help | grep phx tasks? It is phx.blah not phoenix.blah. ^.^

This is what I get, its funtoo linux though…

$ mix help | egrep "phx|phoenix"
mix local.phoenix     # Updates Phoenix locally
mix local.phx         # Updates the Phoenix project generator locally
mix phoenix.new       # Creates a new Phoenix v1.3.0 application
mix phx.new           # Creates a new Phoenix v1.3.0 application
mix phx.new.ecto      # Creates a new Ecto project within an umbrella project
mix phx.new.web       # Creates a new Phoenix web project within an umbrella project

Of course you need to make sure that you are actually using the correct elixir version!

In your case I’d try this to be sure:

$ ASDF_ELIXIR_VERSION=1.5.1 mix help | egrep "phoenix|phx"

If that does really print nothing, please do show the full output of ASDF_ELIXIR_VERSION=1.5.1 mix help and which mix!

The error is occurring both on new phx apps and old ones.

mix compile
==> apartmentex
Compiling 5 files (.ex)

== Compilation error in file lib/apartmentex/migrations_path_builder.ex ==
** (CompileError) lib/apartmentex/migrations_path_builder.ex:2: cannot import Mix.Ecto.build_repo_priv/1 because it is undefined or private
    (elixir) src/elixir_import.erl:77: :elixir_import.calculate/6
    (elixir) src/elixir_import.erl:18: :elixir_import.import/4
could not compile dependency :apartmentex, "mix compile" failed. You can recompile this dependency with "mix deps.compile apartmentex", update it with "mix deps.update apartmentex" or clean it with "mix deps.clean apartmentex"

This command output works:

ASDF_ELIXIR_VERSION=1.5.1 mix help | egrep "phoenix|phx"
mix local.phoenix      # Updates Phoenix locally
mix local.phx          # Updates the Phoenix project generator locally
mix phoenix.gen.html   # Generates controller, model and views for an HTML based resource
mix phoenix.new        # Creates a new Phoenix v1.3.0 application
mix phoenix.server     # Starts applications and their servers
mix phx.digest         # Digests and compresses static files
mix phx.digest.clean   # Removes old versions of static assets.
mix phx.gen.channel    # Generates a Phoenix channel
mix phx.gen.context    # Generates a context with functions around an Ecto schema
mix phx.gen.embedded   # Generates an embedded Ecto schema file
mix phx.gen.html       # Generates controller, views, and context for an HTML resource
mix phx.gen.json       # Generates controller, views, and context for a JSON resource
mix phx.gen.presence   # Generates a Presence tracker
mix phx.gen.schema     # Generates an Ecto schema and migration file
mix phx.gen.secret     # Generates a secret
mix phx.new            # Creates a new Phoenix v1.3.0 application
mix phx.new.ecto       # Creates a new Ecto project within an umbrella project
mix phx.new.web        # Creates a new Phoenix web project within an umbrella project
mix phx.routes         # Prints all routes
mix phx.server         # Starts applications and their servers

Then create properly filled .tool-versions file in your project root as described in asdfs README:

Maybe you can also set a global version as you require it via asdf global elixir 1.5.1.

1 Like

Also let me please say, that asdf is not a packagemanager like apt or brew which installs elixir or something else in the required version, its a tool that manages environments and therefore need to be learned to be able to use it correctly. Its much more like rbenv, rvm, rustup, evm, etc…

But if one has mastered it, one can use it to run tests automatically against mutliple Erlang/Elixir-Version-Combinations without having to rely or configure external CI Services. Therefore you can get a level of confidence your code is correct for all targeted environments even before pushing it to the public.

I made an asdf quickstart tutorial a while back that goes through installing languages and Phoenix. I still use it when setting up new machines.

It might help as a quick check to see if there’s something you’re missing.

3 Likes