mattfara50

mattfara50

Ecto not starting or unavailable in local dependency project

I have a LiveView app (generated with the --no-ecto option) which depends on a local backend app. The backend app depends on Ecto. When I start the LiveView app, Ecto is apparently not starting:

LiveView app mix.exs:

  defp deps do
    [
      ...
      {:back_project, path: "../backend_project/"},
    ]
  end

Error upon running mix phx.server:

[error] #PID<0.686.0> running Phoenix.Endpoint.SyncCodeReloadPlug (connection #PID<0.685.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: GET /
** (exit) an exception was raised:
    ** (RuntimeError) could not lookup Ecto repo BackendProject.Repo because it was not started or it does not exist

How do I force Ecto to start when I start the LiveView app?

I tried naming the dependency’s repo in the LiveView app’s application.ex, but this just gave me a cryptic error upon starting phx server:

erl_child_setup: failed with error 32 on line 281
[notice] Application liveview_app exited: shutdown

Marked As Solved

mattfara50

mattfara50

I added an entry to the LiveView app’s config, like

config :backend_project, ecto_repos: [BackendProject.Repo]
and repeated the full backend Repo configuration as it was presented in the backed config/config.exs app.

I did not supervise the backend repo from the LiveView app.

I guess this solution worked because the config in the dependency is ignored completely?

Also Liked

axelson

axelson

Scenic Core Team

I guess this solution worked because the config in the dependency is ignored completely?

Yeah that’s it! Here’s where it’s listed in the docs (from: Config — Elixir v1.15.6):

Also note that the config/config.exs of a library is not evaluated when the library is used as a dependency, as configuration is always meant to configure the current project. For more information, read our library guidelines.

Where Next?

Popular in Questions Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
Mooodi
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work. Or rather, not char, but a substr...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
jc00ke
Expanding on this topic: https://forum.elixirforum.net/t/map-typespec-question/19217 Let’s say I have a map with required and optional k...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

Other popular topics Top

pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New

We're in Beta

About us Mission Statement