Running a project with another project as dependency, but not in umbrella

Hi everybody
I’m writing a service that consists in two separated projects, not inside an umbrella, where one project references the other as a dependency with the path key.
The referenced one runs without any problem when run isolated, but it can’t start when being used referenced by the other.

Project1 is a phoenix app, but I think this has nothing to do with the problem.

I think that the problem is that when started from the other one the config files could not be read, so it fails to start as an app.

I have this error

** (ArgumentError) could not fetch application environment :project_id for application :project2 because the application was not loaded/started. If your application depends on :project2 at runtime, make sure to load/start it or list it under :extra_applications in your mix.exs file

But it’s not helpful, the suggestion does not work.
Can I use some configuration to achieve what I want?
Thanks

Ok, I just auto reply me.
I see that I can import the project2 config files into my project1 config files.
And then the project2 can start properly

for config <- "../../project2/config/config.exs" |> Path.expand(__DIR__) |> Path.wildcard() do
  import_config config
end

This is not what you want.

You want to add configuration for project2 in the config/foo.exs of project1.

1 Like

What I did was import configuration of project2 inside project1/config/config.exs with just one sentence so I don’t have to repeat code in both projects.
import_config "../../project2/config/config.exs"
But I understand your point.
I can override when I need.
Thanks

This is not how configs are supposed to work.

If you want to have defaults for your configs, then you’ll need to provide those from your other application. eg Application.get_env(:project2, :port) || 8080 when starting.