larskris
larskris

Reputation: 306

How to use local environment variables that don't belong to a library?

I have some variables that depend on the environment. They don't belong to a deps library but the only way I know is to import them like if they were. I import them them in config.exs like this:

config :martin,
  url: "http://localhost:4001"

I then define the different urls for production and staging in staging.exs and prod.exs and it is working fine.

But I get this warning for each of the variables I import this way

You have configured application :martin 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 :martin exists or remove the configuration.

Is there a way to do it in a more correct way that won't trigger a warning?

Upvotes: 0

Views: 84

Answers (1)

ryanwinchester
ryanwinchester

Reputation: 12127

You can use the name of your app instead...

config :my_app,
  martin_url: "http://localhost:4001"

Upvotes: 3

Related Questions