Skip to content

Commit cce4db1

Browse files
michalmuskalaJosé Valim
authored andcommitted
Improve documentation for Mix.env/0,1 (#6308)
1 parent 5398508 commit cce4db1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/mix/lib/mix.ex

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,15 @@ defmodule Mix do
201201

202202
@doc """
203203
Returns the Mix environment.
204+
205+
This function should not be used at runtime in application code (as opposed
206+
to infrastructure and build code like Mix tasks). Mix is a build tool and may
207+
not be available after the code is compiled (for example in a release).
208+
209+
To differentiate the program behavior depending on the environment, it is
210+
recommended to use application environment through `Application.get_env/3`.
211+
Proper configuration can be set in `Mix.Config` files, often per-environment
212+
(see `Mix.Config.import_config/1` for more information).
204213
"""
205214
def env do
206215
# env is not available on bootstrapping, so set a :dev default
@@ -212,6 +221,9 @@ defmodule Mix do
212221
213222
Be careful when invoking this function as any project
214223
configuration won't be reloaded.
224+
225+
This function should not be used at runtime in application code
226+
(see `env/0` for more information).
215227
"""
216228
def env(env) when is_atom(env) do
217229
Mix.State.put(:env, env)

0 commit comments

Comments
 (0)