In Phoenix Framework, how can I get the current environment's name ?
I've already tried reading env
variables with System.get_env("MIX_ENV")
, but the value is not always set.
Create a new environment After creating your new environment, you can run conda env list to check your new environment. The environments created by Conda is always located in /Users/.../anaconda3/envs/ . You may change the default location by using the following command but it is not encouraged.
If you activate the environment you're interested in, you can find that answer in the environment variables. You can also run conda info --envs , and that will show the paths to all your environments. That should return the path you're looking for.
Open the notebook in Jupyter Notebooks and look in the upper right corner of the screen. It should say, for example, "Python [env_name]" if the language is Python and it's using an environment called env_name.
Mix.env()
doesn't work in production or other environments where you use compiled releases (built using Exrm / Distillery) or when Mix
just isn't available.
The solution is to specify it in your config/config.exs
file:
config :your_app, env: Mix.env()
You can then get the environment atom in your application like this:
Application.get_env(:your_app, :env) #=> :prod
You can use Mix.env/0
:
iex(1)> Mix.env :dev
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With