Ecto compile error inquiry

Does anyone know why I am receiving these errors (warnings) in compile time? It is confusing to ask me to not use things, when I have not written any code yet. It’s a new project.

Erlang/OTP 21 [erts-10.3] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [hipe]
Elixir 1.8.1 (compiled with Erlang/OTP 21)

Which warnings do you mean?

Those created by your dependencies? You can’t do much about them, but most of the time you can ignore them.

If though you mean the call to action created by ecto, to add your newly created repo to the supervision tree, then, this is not a warning, but an instruction to you what to do next, that you actually can use the created repo. It can’t be done automatically since supervision trees tend to grow very differently in different applications, also there is no central place to let them grow.


Thanks for your response. I do not mean Ecto’s advice for the supervision tree. I specifically meant for the following errors for using depreciated stuff. I can ignore them, but I would like to know if there was anything I could do to prevent them, like… using different versions of my setup:

warning: Enum.partition/2 is deprecated. Use Enum.split_with/2 instead
warning: Inspect.Algebra.surround_many/5 is deprecated. Use Inspect.Algebra.container_doc/6 in                                                                                                  stead

You can try to update ecto and postgrex, at the end your dependencies have to fix those warnings, but if they have been introduced recently, it might be that the code is kept backwards compatible for about another year until a bump of minimal elixir version allows to fix the warning.

Ok so basically I was following the tutorial on on this page. And this configuration they recommended, as far as I understand it should allow mix deps.get to get anything above the mentioned versions, which I assume is the latest versions.

  defp deps do
      {:ecto, "~> 2.0"},
      {:postgrex, "~> 0.11"}

Is there another syntax for this same configuration that allows to fetch latest versions?

The latest version of ecto is 3.x, as it is not compatible with the specified ~> 2.0 mix won’t consider it. And if you follow that tutorial you should probably stick to the versions used there.

I’m not sure if there is a newer release to postgrex that wouldn’t be Denver compatible, and as I’m on mobile it’s not easy to look up.

Basically ~> 2.0 means >= 2.0 and < 3.0.

1 Like

Thanks :slight_smile:

Ok :slight_smile: after cleaning old deps and upgrading ecto to 3.0 and postgrex to 0.14, the configuration made for Example.Repo did not compile due to depreciated syntax.

    defmodule Example.Repo do
      use Ecto.Repo,
        otp_app: :friends,
        adapter: Ecto.Adapters.Postgres

  lib/ecto/repo/supervisor.ex:100: Ecto.Repo.Supervisor.deprecated_adapter/3
  lib/ecto/repo/supervisor.ex:64: Ecto.Repo.Supervisor.compile_config/2
  lib/example/repo.ex:2: (module)
  (elixir) src/elixir_compiler.erl:79: :elixir_compiler.dispatch/4
  (elixir) src/elixir_compiler.erl:63: :elixir_compiler.compile/3

== Compilation error in file lib/example/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/example/repo.ex:2: (module)
    (stdlib) erl_eval.erl:680: :erl_eval.do_apply/6

So you are right, I should theoretically stick with the versions mentioned in the elixir school page if I want the tutorial to succeed.

But on the other hand I think to myself (in loud voice here) what’s the point of learning depreciated syntax? Now I guess I will again, stick to my more solid plan to refer only to official documentation such as and elixir-lang because as it shows every time I try a tutorial/book/course that is not official it turns out to be outdated. Which makes sense, since they’re not the original developers who continuously change/improve their code base.

It’s not because of deprecated syntax, it’s because of incompatible changes from ecto 2.x to 3.x, especially splitting out ecto_sql, which you now need to add also, and to configure differently. It’s fine to learn by the ecto 2.0 resource first and then following an update guide, that should give you enough understanding of ecto.

It hasn’t changed that much, but the split was what made everything incompatible and a breaking change from a semver perspective.

But yes, using a more up to date guide might be a good decision as well :wink: