Skip to content

Commit bd99dcc

Browse files
committed
Add warning around runtime modification of compile env
1 parent 5deee85 commit bd99dcc

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

lib/elixir/lib/application.ex

+11-12
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ defmodule Application do
5454
You can also change the application environment dynamically by using functions
5555
such as `put_env/3` and `delete_env/2`.
5656
57-
> #### Environment in libraries {: .tip}
57+
> #### Application environment in libraries {: .info}
5858
>
59-
> The config files `config/config.exs` and `config/runtime.exs`
60-
> are rarely used by libraries. Libraries typically define their environment
61-
> in the `application/0` function of their `mix.exs`. Configuration files
62-
> are rather used by applications to configure their libraries.
59+
> If you are writing a library to be used by other developers,
60+
> it is generally recommended to avoid the application environment, as the
61+
> application environment is effectively a global storage. For more information,
62+
> read our [library guidelines](library-guidelines.md).
6363
6464
> #### Reading the environment of other applications {: .warning}
6565
>
@@ -673,13 +673,6 @@ defmodule Application do
673673
> You must use this function to read only your own application
674674
> environment. Do not read the environment of other applications.
675675
676-
> #### Application environment in libraries {: .info}
677-
>
678-
> If you are writing a library to be used by other developers,
679-
> it is generally recommended to avoid the application environment, as the
680-
> application environment is effectively a global storage. For more information,
681-
> read our [library guidelines](library-guidelines.md).
682-
683676
## Examples
684677
685678
`get_env/3` is commonly used to read the configuration of your OTP applications.
@@ -796,6 +789,12 @@ defmodule Application do
796789
@doc """
797790
Puts the `value` in `key` for the given `app`.
798791
792+
> #### Compile environment {: .warning}
793+
>
794+
> Do not use this function to change environment variables read
795+
> via `Application.compile_env/2`. The compile environment must
796+
> be exclusively set before compilation, in your config files.
797+
799798
## Options
800799
801800
* `:timeout` - the timeout for the change (defaults to `5_000` milliseconds)

0 commit comments

Comments
 (0)