I am not able to create my Phoenix project. Would love some advice on how to fix it.
Setup details:
I am following the Phoenix Up and Running to make an app.
mix phx.new hello cd hello mix ecto.create
last command gives me:
== Compilation error in file lib/hello/repo.ex == ** (ArgumentError) adapter Ecto.Adapters.Postgres was not compiled, ensure it is correct and it is included as a project dependency lib/ecto/repo/supervisor.ex:71: Ecto.Repo.Supervisor.compile_config/2 lib/hello/repo.ex:2: (module) (stdlib) erl_eval.erl:680: :erl_eval.do_apply/6 (elixir) lib/kernel/parallel_compiler.ex:206: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/6
I have postgres installed. I have postgres super user.
Starting with Ecto 3.0, Ecto.Adapters.Postgres
is not shipped with Ecto by default, therefore you have to add ecto_sql
to the Mixfile dependencies:
########### # mix.exs # ########### defp deps do [ # (...) {:ecto_sql, "~> 3.0-rc.1"}, {:postgrex, ">= 0.0.0"} ] end # Feeling skittish about dependencies, # I usually do this instead of simply # doing `mix deps.get`: $ mix deps.clean --all $ mix do deps.get, compile
(The Ecto github repo v3.0.0 tree recommends {:ecto_sql, "~> 3.0"}
, but the latest release is the 3.0.0-rc.1
) therefore it won't work as of now. Interestingly there is no 3.0.0-rc.1
tag in the repo, but the documentation already refers to that and it also works with mix
.)
...or, as Yufrend recommends in his answer, if you are starting a new Phoenix project, use < 1.4.0 packages.
See José Valim's “A sneak peek at Ecto 3.0” series where the first post explains the breaking changes in Ecto 3.0:
Split Ecto into
ecto
andecto_sql
Ecto 3.0 will be broken in two repositories:
ecto
andecto_sql
. Since Ecto 2.0, an increased number of developers and teams have been using Ecto for data mapping and validation, without a need for a database. However, adding Ecto to your application would still bring a lot of the SQL baggage, such as adapters, sandboxes and migrations, which many considered to be a mixed message.In Ecto 3.0, we will move all of the SQL adapters to a separate repository and Ecto will focus on the four building blocks: schemas, changesets, queries and repos. You can see the discussion in the issues tracker.
If you are using Ecto with a SQL database, migrating to Ecto 3.0 will be very straight-forward. Instead of:
{:ecto, "~> 2.2"}
You should list:
{:ecto_sql, "~> 3.0"}
And if you are using Ecto only for data manipulation but with no database access, then it is just a matter of bumping its version. That’s it!
UPDATE
For some reason, I also needed to add {:plug_cowboy, "~> 1.0"}
to the Mixfile dependencies when updating a Phoenix 1.3 project and it all started working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With