mix ecto.gen.repo -r Friends.Repo not generating

Hi,

I am just trying to learn ecto from the basic guide, following the steps here:

https://hexdocs.pm/ecto/3.5.8/getting-started.html

However, when i get to the step to run “mix ecto.gen.repo -r Friends.Repo”, i get this error:

“** (Mix) ecto.gen.repo expects the repository to be given as -r MyApp.Repo”

I have crawled the internet for answers, but I can’t find anything else than suggestions on creating the necessary files for the repo manually.

Anyone has any other suggestions so i can run the code to generate it automatically?

I just when through the steps in the documentation and even cut/paste the ecto.gen.repo command from your post. It all “just worked”. I also tried a couple off-instruction things
(like no mix deps.get) where I expected errors (and got them), but they were all different errors to the one you’re reporting.

Others might have suggestions, but I’d need to see more details about specifically what you’re doing that gets you to that error. Also, what OS, versions of Elixir, Erlang, etc. just so all the bases are covered?

Here’s a sample of my going through guide you linked to in my environment:

╭─    /wrk/src ────────────────────────────────── 18:35:15
╰─❯ mix new friends --sup
* creating README.md
* creating .formatter.exs
* creating .gitignore
* creating mix.exs
* creating lib
* creating lib/friends.ex
* creating lib/friends/application.ex
* creating test
* creating test/test_helper.exs
* creating test/friends_test.exs

Your Mix project was created successfully.
You can use "mix" to compile it, test it, and more:

    cd friends
    mix test

Run "mix help" for more commands.

╭─    /wrk/src ────────────────────────────────── 18:35:31
╰─❯ cd friends/

>>>>>>>> Edit mix.exs in text editor to add Ecto & Postgrex dependencies

╭─    /wrk/src/friends ──────────────────────────  1.18.1  18:36:09
╰─❯ mix deps.get
Resolving Hex dependencies...
Resolution completed in 0.124s
New:
  db_connection 2.7.0
  decimal 2.3.0
  ecto 3.12.5
  ecto_sql 3.12.1
  postgrex 0.19.3
  telemetry 1.3.0
* Getting ecto_sql (Hex package)
* Getting postgrex (Hex package)
* Getting db_connection (Hex package)
* Getting decimal (Hex package)
* Getting telemetry (Hex package)
* Getting ecto (Hex package)

╭─    /wrk/src/friends ──────────────────────────  1.18.1  18:36:47
╰─❯ mix ecto.gen.repo -r Friends.Repo
==> decimal
Compiling 4 files (.ex)
Generated decimal app
==> friends
===> Analyzing applications...
===> Compiling telemetry
==> db_connection
Compiling 17 files (.ex)
Generated db_connection app
==> ecto
Compiling 56 files (.ex)
Generated ecto app
==> postgrex
Compiling 68 files (.ex)
Generated postgrex app
==> ecto_sql
Compiling 25 files (.ex)
Generated ecto_sql app
==> friends
* creating lib/friends
* creating lib/friends/repo.ex
* creating config/config.exs
Don't forget to add your new repo to your supervision tree
(typically in lib/friends/application.ex):

    def start(_type, _args) do
      children = [
        Friends.Repo,
      ]

And to add it to the list of Ecto repositories in your
configuration files (so Ecto tasks work as expected):

    config :friends,
      ecto_repos: [Friends.Repo]
3 Likes

Hi!

Thank you for replying!

I just found some documentation suggesting I could use the flag --repo instead of just -r.

That solved it for me. Possibly powershell just being difficult :sweat_smile:

1 Like