适配器 Ecto.Adapters.Postgres 未编译
adapter Ecto.Adapters.Postgres was not compiled
我无法创建 Phoenix 项目。想要一些关于如何修复它的建议。
设置详情:
- Ubuntu 16.04.4 LTS
- Erlang/OTP 21 [erts-10.1] [来源] [64 位]
[smp:1:1] [ds:1:1:10] [异步线程数:1] [hipe]
- Elixir 1.7.3(已编译
Erlang/OTP 20)
- Mix 1.7.3(用Erlang/OTP20编译)
- Ecto v3.0.0
我正在关注 Phoenix Up and Running 制作应用程序。
mix phx.new hello
cd hello
mix ecto.create
最后一个命令给我:
== 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
我安装了 postgres。我有 postgres 超级用户。
你的依赖中有 phoenix_ecto
3.5.0 吗?降级到 3.4.0 对我来说是一种临时修复,直到我找出根本问题。
强制降级:
- 运行
mix deps.clean --all
- 删除您的
mix.lock
文件
- 更新限制
phoenix_ecto
版本的 mix.exs
文件。找到合适的行并替换为:
{:phoenix_ecto, ">= 3.2.0 and < 3.5.0"},
- 运行
mix deps.get
或者,如果你刚开始使用Phoenix,你可以使用1.4版本来学习,很快就会发布,没有这个问题。
首先删除您当前的本地 Phoenix 存档:
mix archive.uninstall phx_new
然后,要安装最新的开发版本,请按照https://github.com/phoenixframework/phoenix/blob/master/installer/README.md
中的说明进行操作
从 Ecto 3.0 开始,默认情况下 Ecto.Adapters.Postgres
不随 Ecto 一起提供,因此您必须将 ecto_sql
添加到 Mixfile 依赖项中:
###########
# 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 已经提到了它并且它也适用于 mix
.)
...或者,如 ,如果您正在开始一个新的 Phoenix 项目,请使用 < 1.4.0 包。
请参阅 José Valim 的 “A sneak peek at Ecto 3.0” series,其中第一个 post 解释了 Ecto 3.0 中的重大变化:
Split Ecto into ecto
and ecto_sql
Ecto 3.0 will be broken in two repositories: ecto
and ecto_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!
更新
出于某种原因,我还需要在更新 Phoenix 1.3 项目时将 {:plug_cowboy, "~> 1.0"}
添加到 Mixfile 依赖项中,然后一切都开始工作了。
安装新的 phoenix 版本对我有用。
卸载旧版本:
mix archive.uninstall phx_new
安装新版本:
mix archive.install hex phx_new 1.4.0-rc.2
新项目
要使用 Ecto 3.0
创建新项目,强烈建议您升级到新的 phoenix 1.4.x
安装程序:
$ mix archive.uninstall phx_new
$ mix archive.install hex phx_new 1.4.0-rc.2
现有项目
要将您现有的 Phoenix 1.3.x
项目升级到 1.4
,请阅读 Official Upgrade Guide and the accompanying announcement。
TLDR是Ecto
被打成子包,需要明确指定:
Remove your explicit :ecto
dependency and update your :phoenix_ecto
and :ecto_sql
dependencies with the following versions:
{:ecto_sql, "~> 3.0-rc"},
{:phoenix_ecto, "~> 4.0"},
我无法创建 Phoenix 项目。想要一些关于如何修复它的建议。
设置详情:
- Ubuntu 16.04.4 LTS
- Erlang/OTP 21 [erts-10.1] [来源] [64 位] [smp:1:1] [ds:1:1:10] [异步线程数:1] [hipe]
- Elixir 1.7.3(已编译 Erlang/OTP 20)
- Mix 1.7.3(用Erlang/OTP20编译)
- Ecto v3.0.0
我正在关注 Phoenix Up and Running 制作应用程序。
mix phx.new hello
cd hello
mix ecto.create
最后一个命令给我:
== 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
我安装了 postgres。我有 postgres 超级用户。
你的依赖中有 phoenix_ecto
3.5.0 吗?降级到 3.4.0 对我来说是一种临时修复,直到我找出根本问题。
强制降级:
- 运行
mix deps.clean --all
- 删除您的
mix.lock
文件 - 更新限制
phoenix_ecto
版本的mix.exs
文件。找到合适的行并替换为:{:phoenix_ecto, ">= 3.2.0 and < 3.5.0"},
- 运行
mix deps.get
或者,如果你刚开始使用Phoenix,你可以使用1.4版本来学习,很快就会发布,没有这个问题。
首先删除您当前的本地 Phoenix 存档:
mix archive.uninstall phx_new
然后,要安装最新的开发版本,请按照https://github.com/phoenixframework/phoenix/blob/master/installer/README.md
中的说明进行操作从 Ecto 3.0 开始,默认情况下 Ecto.Adapters.Postgres
不随 Ecto 一起提供,因此您必须将 ecto_sql
添加到 Mixfile 依赖项中:
###########
# 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 已经提到了它并且它也适用于 mix
.)
...或者,如
请参阅 José Valim 的 “A sneak peek at Ecto 3.0” series,其中第一个 post 解释了 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!
更新
出于某种原因,我还需要在更新 Phoenix 1.3 项目时将 {:plug_cowboy, "~> 1.0"}
添加到 Mixfile 依赖项中,然后一切都开始工作了。
安装新的 phoenix 版本对我有用。
卸载旧版本:
mix archive.uninstall phx_new
安装新版本:
mix archive.install hex phx_new 1.4.0-rc.2
新项目
要使用 Ecto 3.0
创建新项目,强烈建议您升级到新的 phoenix 1.4.x
安装程序:
$ mix archive.uninstall phx_new
$ mix archive.install hex phx_new 1.4.0-rc.2
现有项目
要将您现有的 Phoenix 1.3.x
项目升级到 1.4
,请阅读 Official Upgrade Guide and the accompanying announcement。
TLDR是Ecto
被打成子包,需要明确指定:
Remove your explicit
:ecto
dependency and update your:phoenix_ecto
and:ecto_sql
dependencies with the following versions:{:ecto_sql, "~> 3.0-rc"}, {:phoenix_ecto, "~> 4.0"},