"Ecto.Adapters.Postgres was not compiled..." After Upgrading Dependencies

I inherited an Elixir app from a now absent supervisor. My skills with Elixir and Phoenix are not great.

I need to upgrade my dependencies so I can get this thing to use TLS3. Here’s the error:

== Compilation error in file lib/[redacted]/repo.ex ==
** (ArgumentError) adapter Ecto.Adapters.Postgres was not compiled, ensure it is correct and it is included as a project dependency
(ecto 3.10.3) lib/ecto/repo/supervisor.ex:61: Ecto.Repo.Supervisor.compile_config/2
lib/[redacted]/repo.ex:3: (module)

The file in question:

defmodule CloHubspot.Repo do

	use Ecto.Repo,
	    otp_app: :clo_hubspot,
	    adapter: Ecto.Adapters.Postgres
end

The relevant bit of mix.exs:

defp deps do
	[
		{:phoenix, "~> 1.7.7"},
		{:phoenix_ecto, "~> 4.4.2"},
		{:ecto, "~> 3.10.3"},
		{:ecto_sql, "~> 3.10.1"},
		{:postgrex, "~> 0.17"},
		{:phoenix_html, "~> 3.3.1"},
		{:phoenix_live_reload, "~> 1.4.1", only: :dev},
		{:plug_cowboy, "~> 2.6"},
		{:httpoison, "~> 2.1.0"},
		{:poison, "~> 5.0.0"},
		{:hound, "~> 1.1.1"},
		{:cors_plug, "~> 3.0.3"},
		{:credo, "~> 1.7.0", only: [:dev, :test]},
		{:jason, "~> 1.4.1"}
	]
end

Erlang/Elixir versions:

Erlang/OTP 26 [erts-14.0.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns] [dtrace]
Elixir 1.15.4 (compiled with Erlang/OTP 26)

I suspect my wanton upgrade of every @#$%@#$% thing broke postgres. Does anybody know where I ought to be?

How did you update your dependencies? You can always try mix deps.compile --all. If this doesn’t solve the problem, you can try mix clean --deps && mix deps.get && mix deps.compile --all

1 Like

To be fair that usually ends in tears, you are better off reverting that “upgrade everything” commit and start with only upgrading Erlang and Elixir. Then upgrade only Ecto and nothing else, then postgrex, and keep running tests until something breaks.

It’s a crappy job but we have to do it sometimes.

2 Likes

That worked! Thank you.

Next time, that will be the far more sensible plan. For this one, I’ve got about three miles of warning messages to wade through.

1 Like

I spoke to soon. The deps rebuilt nicely but the phoenix app, not so much. Thanks for the pointer on mix clean, though. That’s very helpful.

1 Like

And now I’m making it the plan for this time. Thanks. I’ll post here on the results for posterity.

1 Like