What versions of Erlang and Elixir are needed for Phoenix 1.4?

What versions of Erlang and Elixir are needed for Phoenix 1.4? I tried a lot of versions and never managed to run Phoenix 1.4. Errors appear when creating a database. There are different errors on different versions of Erlang and Elixir. I spent 2 days looking through versions and still couldn’t find the right ones. I tried changing the path variables for Erlang and Elixir, but it didn’t help.

mix ecto.create and mix phx.server never worked without errors. Although I have postgres, hex… Although I have postgres, hex.

It would help if you post the error messages. Technically there should not be any limitations of Erlang/Elixir versions per se.

1 Like

It is very hard to know without looking at the errors. Do the projects even compile fine?

In any case, latest v1.4 was release on April 2020 and the Elixir release at the time was v1.10. Compatible OTP versions can be found here: Compatibility and Deprecations — Elixir v1.15.5

5 Likes

Errors appear when creating a database

Erlang/OTP 23 [erts-11.2.2.18] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]

Elixir 1.10.0 (compiled with Erlang/OTP 21)

Phoenix 1.4.17

mix ecto.create
==> file_system
Compiling 7 files (.ex)
Generated file_system app
==> hello
Could not find "rebar3", which is needed to build dependency :ranch
I can install a local copy which is just used by Mix
Shall I install rebar3? (if running non-interactively, use "mix local.rebar --force") [Yn] y
* creating c:/Users/user/.mix/rebar
* creating c:/Users/user/.mix/rebar3
===> Compiling ranch
===> Compiling telemetry
==> decimal
Compiling 4 files (.ex)
Generated decimal app
==> jason
Compiling 10 files (.ex)
Generated jason app
==> db_connection
Compiling 15 files (.ex)
warning: calling super for GenServer callback child_spec/1 is deprecated
  lib/db_connection/connection_pool.ex:25: DBConnection.ConnectionPool.child_spec/1

Generated db_connection app
==> expo
warning: the dependency :expo requires Elixir "~> 1.11" but you are running on v1.10.0
Compiling 2 files (.erl)
Compiling 21 files (.ex)
Generated expo app
==> gettext
warning: the dependency :gettext requires Elixir "~> 1.11" but you are running on v1.10.0
Compiling 17 files (.ex)
Generated gettext app
==> ecto
Compiling 56 files (.ex)
Generated ecto app
==> phoenix_pubsub
Compiling 13 files (.ex)
warning: Supervisor.Spec.supervise/2 is deprecated. Use the new child specifications outlined in the Supervisor module instead
  lib/phoenix/tracker.ex:Phoenix.Tracker.init/1

warning: Supervisor.Spec.supervise/2 is deprecated. Use the new child specifications outlined in the Supervisor module instead
  lib/phoenix/pubsub/local_supervisor.ex:Phoenix.PubSub.LocalSupervisor.init/1

warning: Supervisor.Spec.supervise/2 is deprecated. Use the new child specifications outlined in the Supervisor module instead
  lib/phoenix/pubsub/pg2.ex:Phoenix.PubSub.PG2.init/1

Generated phoenix_pubsub app
===> Compiling cowlib
===> Compiling cowboy
===> Compiling cowboy_telemetry
==> mime
Compiling 1 file (.ex)
Generated mime app
==> postgrex
warning: the dependency :postgrex requires Elixir "~> 1.11" but you are running on v1.10.0
Compiling 68 files (.ex)

== Compilation error in file lib/postgrex/extensions/timestamp.ex ==
** (UndefinedFunctionError) function NaiveDateTime.to_gregorian_seconds/1 is undefined or private
    (elixir 1.10.0) NaiveDateTime.to_gregorian_seconds(~N[2000-01-01 00:00:00])
    lib/postgrex/extensions/timestamp.ex:6: (module)
    (stdlib 3.14.2.3) erl_eval.erl:680: :erl_eval.do_apply/6
could not compile dependency :postgrex, "mix compile" failed. You can recompile this dependency with "mix deps.compile postgrex", update it with "mix deps.update postgrex" or clean it with "mix deps.clean postgrex"

If we want to find first working version then isn’t it easier to just take an elixir value in Phoenix.MixProject.project/0 function located in mix.exs? Following v1.4 branch the minimum Elixir version is 1.4, see:

If we want to be sure which combinations were tested we can simply check travis.yml which contains all supported Erlang and Elixir matrices:

However we need to be careful with them as according to compatibility table:

  1. Elixir’s 1.4 and 1.5 supports Erlang version 18, but it wasn’t tested in v1.4 branch (it was tested in all 1.1.x, 1.2.x and 1.3.x versions)
  2. Erlang/OTP 20 wasn’t supported before Elixir 1.4.5
  3. Erlang/OTP 21 wasn’t supported before Elixir 1.6.6

So the officially supported (tested in Travis CI) versions for Phoenix 1.4.x are:

  1. Elixir 1.4.0 - 1.4.4 with Erlang/OTP 19.3 - 19.3.6.13
  2. Elixir 1.4.5 with Erlang/OTP 19.3 - 19.3.6.13
  3. Elixir 1.4.5 with Erlang/OTP 20.3 - 20.3.8.26
  4. Elixir 1.5.0 - 1.5.3 with Erlang/OTP 19.3 - 19.3.6.13
  5. Elixir 1.5.0 - 1.5.3 with Erlang/OTP 20.3 - 20.3.8.26
  6. Elixir 1.6.0 - 1.6.5 with Erlang/OTP 19.3 - 19.3.6.13
  7. Elixir 1.6.0 - 1.6.5 withErlang/OTP 20.3 - 20.3.8.26
  8. Elixir 1.6.6 with Erlang/OTP 19.3 - 19.3.6.13
  9. Elixir 1.6.6 with Erlang/OTP 20.3 - 21.3.8.24

Note: The phx.new task as well as guides requires Elixir minimum version 1.5.0

Note: Didn’t included -rc.x releaes as they are release candidates, so they aren’t expected to be stable and therefore recommended for production

Note: Some guides mentions Elixir v1.7 (elixircasts) or Elixir v1.9 (hexdocs)

Helpful resources:

  1. [phoenixframework/phoenix@8dbb260] Remove old generators and require Elixir v1.4+
  2. [phoenixframework/phoenix@49def42] Require Elixir v1.5 for new apps
  3. [phoenixframework/phoenix@a56fdfb] Fix the Elixir minimum version on guide to 1.5
  4. [hexdocs.pm/phoenix v1.4.18] Installation guide
  5. [hexdocs.pm/phoenix v1.4.18] Deploying with Releases
  6. [elixircasts.io using Elixir 1.7] #75: Upgrading to Phoenix 1.4
3 Likes

You need to downgrade dependencies in mix.exs as your current mix.exs tries to use the more recent ones. Those dependencies requires newer Elixir versions than phoenix v1.4.

Try to use those commands:

mix archive.install hex phx_new 1.4.18 --force
mix phx.new example
3 Likes

Thank you

According to the official docs here – NaiveDateTime — Elixir v1.15.5 – the NaiveDateTime.html#to_gregorian_seconds/1 function has been added in Elixir 1.11.

So use at least that. Erlang 22 to 24 should be fine as well.

Since op is asking about Phoenix v1.4 this solution in unrelated i.e. you have answered how to fix specific version of postgrex dependency which as in warning requires Elixir v1.11. To avoid confusion the correct reply is that nothing stops others from downgrading this and other dependencies when needed. It should be especially easier after calling 2 previously mentioned commands to generate phoenix project with old generator.

If you so insist on being overly pedantic: OP never said they have to use Phoenix 1.4; they only asked a question and never clarified why do they use Phoenix 1.4. So I have my doubts that they’re in the middle of the XY problem and offered an alternative that could get them out of it.

2 Likes

Hello, I tried to install these versions.

Erlang/OTP 22 [erts-10.4] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]

Elixir 1.9.4 (compiled with Erlang/OTP 20)

$ mix ecto.create
==> file_system
Compiling 7 files (.ex)
Generated file_system app
==> decimal
Compiling 4 files (.ex)
Generated decimal app
==> jason
Compiling 10 files (.ex)
Generated jason app
==> db_connection
Compiling 15 files (.ex)
warning: calling super for GenServer callback child_spec/1 is deprecated
lib/db_connection/connection_pool.ex:25: DBConnection.ConnectionPool.child_spec/1

Generated db_connection app
==> expo
warning: the dependency :expo requires Elixir “~> 1.11” but you are running on v1.9.4
Compiling 2 files (.erl)
Compiling 21 files (.ex)
Generated expo app
==> gettext
warning: the dependency :gettext requires Elixir “~> 1.11” but you are running on v1.9.4
Compiling 17 files (.ex)
Generated gettext app
==> ecto
warning: the dependency :ecto requires Elixir “~> 1.10” but you are running on v1.9.4
Compiling 56 files (.ex)
warning: redefining module Mix.Ecto (current version loaded from d:/1. Functional programming/Phoenix/phoenix-conspect/01. ╨Ю╤Б╨╜╨╛╨▓╤Л Phoenix/hello/_build/dev/lib/ecto/ebin/Elixir.Mix.Ecto.beam)
lib/mix/ecto.ex:1

warning: redefining module Mix.Tasks.Ecto.Create (current version loaded from d:/1. Functional programming/Phoenix/phoenix-conspect/01. ╨Ю╤Б╨╜╨╛╨▓╤Л Phoenix/hello/_build/dev/lib/ecto/ebin/Elixir.Mix.Tasks.Ecto.Create.beam)
lib/mix/tasks/ecto.create.ex:1

== Compilation error in file lib/ecto/query/planner.ex ==
** (CompileError) lib/ecto/query/planner.ex:1708: cannot find or invoke local is_map_key/2 inside guard. Only macros can be invoked in a guard and they must be defined before their invocation. Called as: is_map_key(drop, field)
(stdlib) lists.erl:1354: :lists.mapfoldl/3
(stdlib) lists.erl:1355: :lists.mapfoldl/3
(elixir) expanding macro: Kernel.and/2
could not compile dependency :ecto, “mix compile” failed. You can recompile this dependency with “mix deps.compile ecto”, update it with “mix deps.update ecto” or clean it with “mix deps.clean ecto”

I also tried it

Erlang/OTP 22 [erts-10.4] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]

Elixir 1.11.0 (compiled with Erlang/OTP 21)

user@WIN-5A0PDOIDA9K MINGW64 /d/1. Functional programming/Phoenix/phoenix-conspect/01. Основы Phoenix/hello (main)
$ mix ecto.create
==> file_system
Compiling 7 files (.ex)
Generated file_system app
==> decimal
Compiling 4 files (.ex)
Generated decimal app
==> jason
Compiling 10 files (.ex)
Generated jason app
==> db_connection
Compiling 15 files (.ex)
warning: calling super for GenServer callback child_spec/1 is deprecated
lib/db_connection/connection_pool.ex:25: DBConnection.ConnectionPool.child_spec/1

Generated db_connection app
==> expo
Compiling 2 files (.erl)
Compiling 21 files (.ex)
Generated expo app
==> gettext
Compiling 17 files (.ex)
Generated gettext app
==> ecto
Compiling 56 files (.ex)
Generated ecto app
==> phoenix_pubsub
Compiling 13 files (.ex)
warning: Supervisor.Spec.supervise/2 is deprecated. Use the new child specifications outlined in the Supervisor module instead
lib/phoenix/tracker.ex:273: Phoenix.Tracker.init/1

warning: Supervisor.Spec.supervise/2 is deprecated. Use the new child specifications outlined in the Supervisor module instead
lib/phoenix/pubsub/local_supervisor.ex:42: Phoenix.PubSub.LocalSupervisor.init/1

warning: Supervisor.Spec.worker/3 is deprecated. Use the new child specifications outlined in the Supervisor module instead
lib/phoenix/tracker.ex:269: Phoenix.Tracker.init/1

warning: Supervisor.Spec.supervisor/3 is deprecated. Use the new child specifications outlined in the Supervisor module instead
lib/phoenix/pubsub/local_supervisor.ex:39: Phoenix.PubSub.LocalSupervisor.init/1

warning: Supervisor.Spec.worker/2 is deprecated. Use the new child specifications outlined in the Supervisor module instead
Found at 2 locations:
lib/phoenix/pubsub/local_supervisor.ex:35: Phoenix.PubSub.LocalSupervisor.init/1
lib/phoenix/pubsub/local_supervisor.ex:36: Phoenix.PubSub.LocalSupervisor.init/1

warning: Supervisor.Spec.supervise/2 is deprecated. Use the new child specifications outlined in the Supervisor module instead
lib/phoenix/pubsub/pg2.ex:97: Phoenix.PubSub.PG2.init/1

warning: Supervisor.Spec.supervisor/2 is deprecated. Use the new child specifications outlined in the Supervisor module instead
lib/phoenix/pubsub/pg2.ex:93: Phoenix.PubSub.PG2.init/1

warning: Supervisor.Spec.worker/2 is deprecated. Use the new child specifications outlined in the Supervisor module instead
lib/phoenix/pubsub/pg2.ex:94: Phoenix.PubSub.PG2.init/1

Generated phoenix_pubsub app
===> Compiling cowboy
===> Rebar3 detected a lock file from a newer version. It will be loaded in compatibility mode, but important information may be missing or lost. It is recommended to upgrade Rebar3.
===> Compiling cowboy_telemetry
==> mime
Compiling 1 file (.ex)
Generated mime app
==> postgrex
Compiling 68 files (.ex)
Generated postgrex app
==> ecto_sql
Compiling 25 files (.ex)
Generated ecto_sql app
==> plug_crypto
Compiling 5 files (.ex)
Generated plug_crypto app
==> plug
Compiling 1 file (.erl)
Compiling 40 files (.ex)
Generated plug app
==> phoenix_html
Compiling 8 files (.ex)
Generated phoenix_html app
==> plug_cowboy
Compiling 5 files (.ex)
Generated plug_cowboy app
==> phoenix
Compiling 67 files (.ex)
warning: System.stacktrace/0 is deprecated, use STACKTRACE instead
lib/phoenix/router.ex:281

warning: System.stacktrace/0 is deprecated, use STACKTRACE instead
lib/phoenix/endpoint/cowboy2_handler.ex:40

warning: System.stacktrace/0 is deprecated, use STACKTRACE instead
lib/phoenix/endpoint/cowboy2_handler.ex:45

warning: System.stacktrace/0 is deprecated, use STACKTRACE instead
lib/phoenix/endpoint/cowboy_websocket.ex:29

warning: duplicate key :route found in struct
(elixir 1.11.0) lib/kernel/utils.ex:119: Kernel.Utils.warn_on_duplicate_struct_key/1
(elixir 1.11.0) lib/kernel/utils.ex:98: Kernel.Utils.defstruct/2
lib/phoenix/router/resource.ex:24: (module)
(elixir 1.11.0) src/elixir_compiler.erl:75: :elixir_compiler.dispatch/4
(elixir 1.11.0) src/elixir_compiler.erl:60: :elixir_compiler.compile/3

warning: System.stacktrace/0 is deprecated, use STACKTRACE instead
lib/phoenix/test/conn_test.ex:661

warning: function actions/1 required by protocol Plug.Exception is not implemented (in module Plug.Exception.Phoenix.ActionClauseError)
lib/phoenix/exceptions.ex:67: Plug.Exception.Phoenix.ActionClauseError (module)

warning: System.stacktrace/0 is deprecated, use STACKTRACE instead
lib/phoenix/code_reloader/server.ex:62

warning: IEx.started?/0 defined in application :iex is used by the current application but the current application does not directly depend on :iex. To fix this, you must do one of:

  1. If :iex is part of Erlang/Elixir, you must include it under :extra_applications inside “def application” in your mix.exs

  2. If :iex is a dependency, make sure it is listed under “def deps” in your mix.exs

  3. In case you don’t want to add a requirement to :iex, you may optionally skip this warning by adding [xref: [exclude: IEx] to your “def project” in mix.exs

lib/mix/tasks/phx.server.ex:40: Mix.Tasks.Phx.Server.iex_running?/0

warning: Supervisor.Spec.supervisor/2 is deprecated. Use the new child specifications outlined in the Supervisor module instead
lib/phoenix.ex:53: Phoenix.start/2

warning: Supervisor.Spec.worker/2 is deprecated. Use the new child specifications outlined in the Supervisor module instead
lib/phoenix.ex:52: Phoenix.start/2

warning: Supervisor.Spec.supervisor/3 is deprecated. Use the new child specifications outlined in the Supervisor module instead
lib/phoenix/socket.ex:507: Phoenix.Socket.child_spec/2

warning: Supervisor.Spec.worker/3 is deprecated. Use the new child specifications outlined in the Supervisor module instead
lib/phoenix/socket.ex:505: Phoenix.Socket.child_spec/2

warning: Supervisor.Spec.worker/2 is deprecated. Use the new child specifications outlined in the Supervisor module instead
lib/phoenix/endpoint/supervisor.ex:89: Phoenix.Endpoint.Supervisor.config_children/3

warning: Supervisor.Spec.supervise/2 is deprecated. Use the new child specifications outlined in the Supervisor module instead
lib/phoenix/transports/long_poll_server.ex:14: Phoenix.Transports.LongPoll.Supervisor.init/1

warning: Supervisor.Spec.worker/3 is deprecated. Use the new child specifications outlined in the Supervisor module instead
lib/phoenix/transports/long_poll_server.ex:11: Phoenix.Transports.LongPoll.Supervisor.init/1

warning: Supervisor.Spec.supervise/2 is deprecated. Use the new child specifications outlined in the Supervisor module instead
lib/phoenix/socket/pool_supervisor.ex:54: Phoenix.Socket.PoolSupervisor.init/1

warning: Supervisor.Spec.supervisor/3 is deprecated. Use the new child specifications outlined in the Supervisor module instead
lib/phoenix/socket/pool_supervisor.ex:51: Phoenix.Socket.PoolSupervisor.init/1

warning: Supervisor.Spec.supervisor/2 is deprecated. Use the new child specifications outlined in the Supervisor module instead
lib/phoenix/presence.ex:307: Phoenix.Presence.start_link/4

warning: Supervisor.Spec.worker/2 is deprecated. Use the new child specifications outlined in the Supervisor module instead
lib/phoenix/presence.ex:308: Phoenix.Presence.start_link/4

Generated phoenix app
==> phoenix_live_reload
Compiling 4 files (.ex)
Generated phoenix_live_reload app
==> phoenix_ecto
Compiling 7 files (.ex)
Generated phoenix_ecto app
warning: the :gettext compiler is no longer required in your mix.exs.

Please find the following line in your mix.exs and remove the :gettext entry:

compilers: [..., :gettext, ...] ++ Mix.compilers(),

(gettext 0.23.1) lib/mix/tasks/compile.gettext.ex:5: Mix.Tasks.Compile.Gettext.run/1
(mix 1.11.0) lib/mix/task.ex:394: Mix.Task.run_task/3
(mix 1.11.0) lib/mix/tasks/compile.all.ex:90: Mix.Tasks.Compile.All.run_compiler/2
(mix 1.11.0) lib/mix/tasks/compile.all.ex:70: Mix.Tasks.Compile.All.compile/4
(mix 1.11.0) lib/mix/tasks/compile.all.ex:57: Mix.Tasks.Compile.All.with_logger_app/2
(mix 1.11.0) lib/mix/tasks/compile.all.ex:35: Mix.Tasks.Compile.All.run/1
(mix 1.11.0) lib/mix/task.ex:394: Mix.Task.run_task/3
(mix 1.11.0) lib/mix/tasks/compile.ex:119: Mix.Tasks.Compile.run/1
(mix 1.11.0) lib/mix/task.ex:394: Mix.Task.run_task/3
(mix 1.11.0) lib/mix/tasks/app.config.ex:30: Mix.Tasks.App.Config.run/1
(mix 1.11.0) lib/mix/task.ex:394: Mix.Task.run_task/3
(ecto 3.10.3) lib/mix/ecto.ex:70: Mix.Ecto.ensure_repo/2
(ecto 3.10.3) lib/mix/tasks/ecto.create.ex:50: anonymous fn/3 in Mix.Tasks.Ecto.Create.run/1
(elixir 1.11.0) lib/enum.ex:786: Enum.“-each/2-lists^foreach/1-0-”/2
(elixir 1.11.0) lib/enum.ex:786: Enum.each/2
(mix 1.11.0) lib/mix/task.ex:394: Mix.Task.run_task/3
(mix 1.11.0) lib/mix/cli.ex:84: Mix.CLI.run_task/2

==> hello
Compiling 13 files (.ex)
warning: System.stacktrace/0 is deprecated, use STACKTRACE instead
lib/hello_web/endpoint.ex:1

warning: System.stacktrace/0 is deprecated, use STACKTRACE instead
lib/hello_web/endpoint.ex

warning: System.stacktrace/0 is deprecated, use STACKTRACE instead
lib/hello_web/endpoint.ex

warning: System.stacktrace/0 is deprecated, use STACKTRACE instead
lib/hello_web/endpoint.ex

warning: System.stacktrace/0 is deprecated, use STACKTRACE instead
lib/hello_web/endpoint.ex

warning: System.stacktrace/0 is deprecated, use STACKTRACE instead
lib/hello_web/endpoint.ex

warning: System.stacktrace/0 is deprecated, use STACKTRACE instead
lib/hello_web/router.ex:4

warning: System.stacktrace/0 is deprecated, use STACKTRACE instead
lib/hello_web/router.ex:12

warning: System.stacktrace/0 is deprecated, use STACKTRACE instead
lib/hello_web/controllers/page_controller.ex:1

warning: incompatible types:

map() !~ atom()

in expression:

# lib/hello_web/router.ex:1
endpoint.static_url

where “endpoint” was given the type atom() in:

# lib/hello_web/router.ex:1
is_atom(endpoint)

where “endpoint” was given the type map() (due to calling var.field) in:

# lib/hello_web/router.ex:1
endpoint.static_url

HINT: “var.field” (without parentheses) implies “var” is a map() while “var.fun()” (with parentheses) implies “var” is an atom()

Conflict found at
lib/hello_web/router.ex:1: HelloWeb.Router.Helpers.static_url/2

Generated hello app

08:08:54.373 [error] Postgrex.Protocol (#PID<0.3601.0>) failed to connect: ** (Postgrex.Error) я┐╜я┐╜я┐╜я┐╜я┐╜ 28P01 (invalid_password) я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜ “postgres” я┐╜я┐╜ я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜ я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜ я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜ (я┐╜я┐╜ я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜)

08:08:54.417 [error] Postgrex.Protocol (#PID<0.3608.0>) failed to connect: ** (Postgrex.Error) я┐╜я┐╜я┐╜я┐╜я┐╜ 28P01 (invalid_password) я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜ “postgres” я┐╜я┐╜ я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜ я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜ я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜ (я┐╜я┐╜ я┐╜я┐╜я┐╜я┐╜я┐╜я┐╜)
** (Mix) The database for Hello.Repo couldn’t be created: killed

Once again dependencies you use for specific Elixir version are too new. If you call 2 commands I proposed above you should have an example project created using old generator which then uses older dependency versions compatible with Elixir. If you have a problem with it I don’t recommend going forward and you should just work on latest Elixir, Erlang/OTP and dependencies versions.

Comp3@DESKTOP-Q1FN4ID MINGW64 ~/Desktop/Новая папка/example
$ elixir -v
Erlang/OTP 19 [erts-8.3] [64-bit] [smp:6:6] [async-threads:10]

Elixir 1.6.0 (compiled with OTP 19)

Comp3@DESKTOP-Q1FN4ID MINGW64 ~/Desktop/Новая папка
$ mix archive.install hex phx_new 1.4.18 --force
Resolving Hex dependencies…
Resolution completed in 0.063s
New:
phx_new 1.4.18

  • Getting phx_new (Hex package)
    Compiling 10 files (.ex)
    Generated phx_new app
    Generated archive “phx_new-1.4.18.ez” with MIX_ENV=prod
  • creating c:/Users/Comp3/.mix/archives/phx_new-1.4.18

Comp3@DESKTOP-Q1FN4ID MINGW64 ~/Desktop/Новая папка
$ mix phx.new example

  • creating example/config/config.exs
  • creating example/config/dev.exs
  • creating example/config/prod.exs
  • creating example/config/prod.secret.exs
  • creating example/config/test.exs
  • creating example/lib/example/application.ex
  • creating example/lib/example.ex
  • creating example/lib/example_web/channels/user_socket.ex
  • creating example/lib/example_web/views/error_helpers.ex
  • creating example/lib/example_web/views/error_view.ex
  • creating example/lib/example_web/endpoint.ex
  • creating example/lib/example_web/router.ex
  • creating example/lib/example_web.ex
  • creating example/mix.exs
  • creating example/README.md
  • creating example/.formatter.exs
  • creating example/.gitignore
  • creating example/test/support/channel_case.ex
  • creating example/test/support/conn_case.ex
  • creating example/test/test_helper.exs
  • creating example/test/example_web/views/error_view_test.exs
  • creating example/lib/example/repo.ex
  • creating example/priv/repo/migrations/.formatter.exs
  • creating example/priv/repo/seeds.exs
  • creating example/test/support/data_case.ex
  • creating example/lib/example_web/controllers/page_controller.ex
  • creating example/lib/example_web/templates/layout/app.html.eex
  • creating example/lib/example_web/templates/page/index.html.eex
  • creating example/lib/example_web/views/layout_view.ex
  • creating example/lib/example_web/views/page_view.ex
  • creating example/test/example_web/controllers/page_controller_test.exs
  • creating example/test/example_web/views/layout_view_test.exs
  • creating example/test/example_web/views/page_view_test.exs
  • creating example/lib/example_web/gettext.ex
  • creating example/priv/gettext/en/LC_MESSAGES/errors.po
  • creating example/priv/gettext/errors.pot
  • creating example/assets/webpack.config.js
  • creating example/assets/.babelrc
  • creating example/assets/js/app.js
  • creating example/assets/js/socket.js
  • creating example/assets/package.json
  • creating example/assets/css/app.css
  • creating example/assets/static/favicon.ico
  • creating example/assets/css/phoenix.css
  • creating example/assets/static/images/phoenix.png
  • creating example/assets/static/robots.txt

Fetch and install dependencies? [Yn] Y

  • running mix deps.get
  • running cd assets && npm install && node node_modules/webpack/bin/webpack.js --mode development

We are almost there! The following steps are missing:

$ cd example
$ cd assets && npm install && node node_modules/webpack/bin/webpack.js --mode development

Then configure your database in config/dev.exs and run:

$ mix ecto.create

Start your Phoenix app with:

$ mix phx.server

You can also run your app inside IEx (Interactive Elixir) as:

$ iex -S mix phx.server

Comp3@DESKTOP-Q1FN4ID MINGW64 ~/Desktop/Новая папка/example
$ mix ecto.create
==> file_system
Compiling 7 files (.ex)
Generated file_system app
==> example
Could not find “rebar3”, which is needed to build dependency :ranch
I can install a local copy which is just used by Mix
Shall I install rebar3? (if running non-interactively, use “mix local.rebar --force”) [Yn] y

  • creating c:/Users/Comp3/.mix/rebar
  • creating c:/Users/Comp3/.mix/rebar3
    ===> Compiling ranch
    ===> Compiling telemetry
    ==> decimal
    warning: the dependency :decimal requires Elixir “~> 1.8” but you are running on v1.6.0
    Compiling 4 files (.ex)
    Generated decimal app
    ==> jason
    Compiling 10 files (.ex)
    warning: function get/3 required by behaviour Access is not implemented (in module Jason.OrderedObject)
    lib/ordered_object.ex:1

Generated jason app
==> db_connection
warning: the dependency :db_connection requires Elixir “~> 1.8” but you are running on v1.6.0
Compiling 15 files (.ex)
warning: variable “STACKTRACE” does not exist and is being expanded to “STACKTRACE()”, please
use parentheses to remove the ambiguity or change the variable name
lib/db_connection/connection.ex:93

warning: variable “STACKTRACE” does not exist and is being expanded to “STACKTRACE()”, please
use parentheses to remove the ambiguity or change the variable name
lib/db_connection/holder.ex:357

== Compilation error in file lib/db_connection/connection.ex ==
** (CompileError) lib/db_connection/connection.ex:93: undefined function STACKTRACE/0
(stdlib) lists.erl:1338: :lists.foreach/2
(stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
could not compile dependency :db_connection, “mix compile” failed. You can recompile this dependency with “mix deps.compile db_connection”, update it with “mix deps.update db_connection” or clean it with
“mix deps.clean db_connection”

Comp3@DESKTOP-Q1FN4ID MINGW64 ~/Desktop/Новая папка/example
$ mix phx.server
==> db_connection
warning: the dependency :db_connection requires Elixir “~> 1.8” but you are running on v1.6.0
Compiling 15 files (.ex)
warning: variable “STACKTRACE” does not exist and is being expanded to “STACKTRACE()”, please
use parentheses to remove the ambiguity or change the variable name
lib/db_connection/connection.ex:93

warning: variable “STACKTRACE” does not exist and is being expanded to “STACKTRACE()”, please
use parentheses to remove the ambiguity or change the variable name
lib/db_connection/holder.ex:357

== Compilation error in file lib/db_connection/connection.ex ==
** (CompileError) lib/db_connection/connection.ex:93: undefined function STACKTRACE/0
(stdlib) lists.erl:1338: :lists.foreach/2
(stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
could not compile dependency :db_connection, “mix compile” failed. You can recompile this dependency with “mix deps.compile db_connection”, update it with “mix deps.update db_connection” or clean it with
“mix deps.clean db_connection”

Comp3@DESKTOP-Q1FN4ID MINGW64 ~/Desktop/Новая папка/example

I tried all these versions but it didn’t help so I tried newer versions. New versions don’t work well either. Errors also appear when creating a database on Phoenix 1.4

Your Elixir 1.11 compilation worked but at the end of the log you have “invalid PostgreSQL password” so that’s the next thing you should validate.

Sounds like you have resolved your original problem.

1 Like

oh, I see … I found few things causing troubles around dependencies:

  1. The generator has been updated several times upgrading dependency definitions :chart_with_upwards_trend:
  2. Some dependencies have or in version and then for older Elixir releases we want to choose (by adding them to deps) lower version :+1:
  3. Some dependencies have introduced updates, that are using functions available since Elixir 1.6.0, in patch release :-1:

Those dependencies should work even with Elixir 1.5.x:

      # unchanged
      {:phoenix_pubsub, "~> 1.1"},
      {:postgrex, ">= 0.0.0"},

      # 1.5.x fix
      {:cowboy, "~> 2.7.0"},
      {:db_connection, "~> 2.0.6"},
      {:decimal, "~> 1.6"},
      {:ecto_sql, "~> 3.1.6"},
      {:gettext, "~> 0.16.1"},
      {:jason, "~> 1.2.2"},
      {:mime, "~> 1.0"},
      # 1.4.12 uses FunctionClauseError.blame/2 available since 1.6.0
      {:phoenix, "< 1.4.12"},
      {:phoenix_ecto, "~> 4.0.0"},
      # 2.11.2 uses Time.truncate/2 available since 1.6.0
      {:phoenix_html, "< 2.11.2"},
      {:phoenix_live_reload, "~> 1.2.4", only: :dev},
      # 1.9.0 introduces actions protocol function which is not supported by phoenix_ecto 4.0.0
      {:plug, "~> 1.8.3"},
      # could be "~> 2.2.2", but 2.2.x versions are retired
      {:plug_cowboy, "~> 2.1.3"},
      {:plug_crypto, "~> 1.1.2"}

When compiling dependencies you should have no warnings except ecto_sql complaining about @impl attribute which is not a big deal for us. After you change your dependencies, recompile everything please follow @dimitarvp response.

3 Likes

I appreciate you giving a full list of safer dependency versions – good job.

I do still believe OP can just stick with Elixir 1.11 and fix his Postgres credentials problem and be done with the whole thing though.

But you are also right that he can do both: (1) specify the dependency versions like you instructed and (2) fix Postgres credentials.

3 Likes

Greetings, thank you very much to dimitarvp and Eiji for your active support and support in this matter. I’m a beginner and this is the first time I’ve encountered this problem. As it turned out, I was not careful with the database password. To summarize, Phoenix 1.4.17 works great on Elixir 1.11 and OTP 22, but errors are already appearing in versions Elixir 1.10 and Elixir 1.12. At least that’s the case for me, maybe I did something wrong. I also successfully ran phoenix version 1.5.7. for elixir 1.11. Thank you all very much.

I need these phoenix versions, since I study at a company where there are projects on these phoenix versions.

Also, special thanks to josevalim, I’m a beginner and didn’t know that I needed to select all the dependencies and environment by the release date of the framework. After I received your message, I did not immediately understand what you meant, but then I understood it.

Please read again my last response. You have warnings because specific versions of same dependency requires different Elixir and sometimes also different Erlang versions. They do so because since x version they use a newer Elixir and/or Erlang/OTP API like new function which simply is not available in previous Elixir and/or Erlang/OTP versions. You can easily navigate on github repositories between their tags and then preview mix.exs file. When you would understand how dependencies works it’s really easy. :books:

Then your company have a serious problem with unmaintained project. :sweat_smile:

Please read the Version module documentation. :open_book:

In short if you have:

{:dep_name, "~> 1.5"}

in your mix.exs then this line is expanded to:

{:dep_name, ">= 1.5.0 and < 2.0.0"}

and the mix tool tries to fetch the newest versions, so if in let’s say 1.7.0 the dependency requires a newer Elixir version then you would have a warnings about missing APIs until you update the Elixir version. :see_no_evil:

You can fight with that code, but it’s not productive in long term. I would recommend to sign an agreement with me to refactor the legacy code to use latest dependencies. I guess that what I wrote already should be more than enough to prove my knowledge. This way you would be able to work much easier without any problems like that and I would add some :moneybag: to my savings. :smiling_imp:

2 Likes