当我创建一个新的应用程序并启动凤凰网络服务器时,如下所示:
$ mix phoenix.new blog
$ cd blog
$ mix phoenix.server
...我收到以下错误:
=INFO REPORT==== 21-Jan-2016::21:57:19 ===
application: logger
exited: stopped
type: temporary
** (Mix) Could not start application blog: Blog.start(:normal, []) returned an error: shutdown: failed to start child: Blog.Repo
** (EXIT) shutdown: failed to start child: Ecto.Adapters.Postgres
** (EXIT) an exception was raised:
** (RuntimeError) could not find Ecto.Adapters.Postgres.Connection.
Please verify you have added :postgrex as a dependency:
{:postgrex, ">= 0.0.0"}
And remember to recompile Ecto afterwards by cleaning the current build:
mix deps.clean ecto
(ecto) lib/ecto/adapters/sql.ex:420: Ecto.Adapters.SQL.start_link/4
(stdlib) supervisor.erl:343: :supervisor.do_start_child/2
(stdlib) supervisor.erl:326: :supervisor.start_children/3
(stdlib) supervisor.erl:292: :supervisor.init_children/2
(stdlib) gen_server.erl:328: :gen_server.init_it/6
(stdlib) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
我已经尝试过我能想到的一切。这似乎与Postgres有关。我尝试过使用postgres 9.5.0和9.4.5。我尝试过使用自制程序和postgresapp安装方法。
我可以使用psql
直接连接到Postgres。而且,我可以使用mix ecto.create
有效地创建数据库。但是,mix ecto.migrate
会抛出相同的错误。
有关我当前设置的一些信息:
这是我的mix.exs
文件:
defmodule Blog.Mixfile do
use Mix.Project
def project do
[app: :blog,
version: "0.0.1",
elixir: "~> 1.0",
elixirc_paths: elixirc_paths(Mix.env),
compilers: [:phoenix, :gettext] ++ Mix.compilers,
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
aliases: aliases,
deps: deps]
end
# Configuration for the OTP application.
#
# Type `mix help compile.app` for more information.
def application do
[mod: {Blog, []},
applications: [:phoenix, :phoenix_html, :cowboy, :logger, :gettext,
:phoenix_ecto, :postgrex]]
end
# Specifies which paths to compile per environment.
defp elixirc_paths(:test), do: ["lib", "web", "test/support"]
defp elixirc_paths(_), do: ["lib", "web"]
# Specifies your project dependencies.
#
# Type `mix help deps` for examples and options.
defp deps do
[{:phoenix, "~> 1.1.3"},
{:phoenix_ecto, "~> 2.0"},
{:postgrex, ">= 0.0.0"},
{:phoenix_html, "~> 2.3"},
{:phoenix_live_reload, "~> 1.0", only: :dev},
{:gettext, "~> 0.9"},
{:cowboy, "~> 1.0"}]
end
# Aliases are shortcut or tasks specific to the current project.
# For example, to create, migrate and run the seeds file at once:
#
# $ mix ecto.setup
#
# See the documentation for `Mix` for more info on aliases.
defp aliases do
["ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
"ecto.reset": ["ecto.drop", "ecto.setup"]]
end
end