** (Mix) Module XXXXX.Repo is not an Ecto.Repo. Please configure your app accordingly or pass a repo with the -r option.

Hi,
I have recently taken on a new job and as part of that, I have inherited an elixir project. I have followed the readme for the project and I am trying to get it set up however I am failing at the first hurdle.

I know very little about elixir so this may be a very stupid question.
I am in the project directory I have ran

mix deps.get

This works, however when i then run

➜ mix ecto.create          
** (Mix) Module XXXX.Repo is not an Ecto.Repo. Please configure your app accordingly or pass a repo with the -r option.

Where XXXX is the name of the project I get that error message. I have googled and cant find anything that helps.

.tool=versions

elixir 1.6.6-otp-21
erlang 21.0
nodejs 11.15.0

I was hoping to learn by working on this project…which is needed for work
Thanks! :smiley:

1 Like

You either need to add config/config.exs that will contain:

config :your_app_name, ecto_repos: [XXXX.YourRepoModule]

Or you need to call mix ecto.create -r XXXX.YourRepoModule

3 Likes

Thank you, That has pointed me in the right direction but now i am getting so many other errors :frowning:

Because You are depending on node, I suspect You have an old Phoenix application.

You might start by showing your mix.exs file.

Then You should show the file where there is an error… XXXX.Repo, which should be in lib/xxxx/repo.ex

And show the error log.

Elixir is supposed to have a good error system…

I am guessing it is a really old application

So this is the mix.exs

defmodule Yuri.Mixfile do
  use Mix.Project

  def project do
    [app: :yuri,
     version: "0.0.1",
     elixir: "~> 1.2",
     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: {Yuri, []},
     applications: [:phoenix, :phoenix_pubsub, :phoenix_html, :cowboy, :logger, :gettext,
                    # :postgrex,
                    :phoenix_ecto, :csv, :parallel_stream,
                    :con_cache, :deep_merge, :calendar]]
  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.2.1"},
      {:phoenix_pubsub, "~> 1.0"},
      {:phoenix_ecto, "~> 3.0"},
      # {:postgrex, ">= 0.0.0"},
      {:phoenix_html, "~> 2.6"},
      {:phoenix_live_reload, "~> 1.0", only: :dev},
      {:gettext, "~> 0.11"},
      {:cowboy, "~> 1.0"},
      {:distillery, "~> 0.10"},
      {:csv, "~> 1.4.2"},
      {:con_cache, "~> 0.11.1"},
      {:deep_merge, "~> 0.1.1"},
#      {:gmail, "~> 0.1", git: "git://github.com/craigp/elixir-gmail"},
      {:calendar, ">= 0.17.4"}
    ]
  end

  # Aliases are shortcuts 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"],
     "test": ["ecto.create --quiet", "ecto.migrate", "test"]]
  end
end

Then when I do mix phoenix.server it kind of runs but I get

 Running Yuri.Endpoint with Cowboy using http://localhost:4000
You have configured application :yuir in your configuration file,
but the application is not available.

This usually means one of:

  1. You have not added the application as a dependency in a mix.exs file.

  2. You are configuring an application that does not really exist.

Please ensure :yuir exists or remove the configuration.

But it looks to be defined in there :man_shrugging:

But this seams to be confirmed by the logs which says

[error] no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started

In the browser I get a white screen with plain text that says sales today.

I am so sorry I really don’t know what is going on here at all

It looks You have a typo in some config file…

3 Likes

You may want to try to run it inside a docker container mirroring the Phoenix, Elixir and Erlang versions of the time the app was built and/or is being used in production.

1 Like

It should be the case because of the .tool-versions file.

1 Like

That assumes that he will be using something that reads it and properly sets up the environment for him? Maybe he is not using any such tool?

1 Like

I think it won’t start if the versions does not match…

2 Likes

That may be the case when the constrains in the mix,exs files are clearly violated, but in his case the mix.exs says at least Phoenix 1.2, therefore violation of constrains may not occur, but I had a lot of issues following tutorials where things didn’t work properly for lots of different issues and nowadays the first thing I do is to create a docker stack with the correct versions for the app, and this approach is working very well for me :slight_smile:

3 Likes

Thank you all.
I am using ASDF and it looks to be using the versions I have in the .tool-versions.

THe original dev got back to me it was missign a .env.dev file which wasnt in the repo.

2 Likes

Quick callout on this - it’s likely needed for the old version this uses, but when you upgrade the project to modern Elixir you’ll want to switch this to extra_applications and remove entries related to dependencies, lest you get strange behavior from Mix.

2 Likes