我定义了一个与guide-started相关的环境变量,我的mix.exs是
defmodule Basic.Mixfile do
use Mix.Project
def project do
[app: :basic,
version: "0.0.1",
elixir: "~> 0.13.0-dev",
deps: deps,
env: [
dev: [foo: "bar"] ] ]
end
# Configuration for the OTP application
#
# Type `mix help compile.app` for more information
def application do
[ applications: [],
mod: { Basic, [] } ]
end
# List all dependencies in the format:
#
# { :foobar, git: "https://github.com/elixir-lang/foobar.git", tag: "0.1" }
#
# Type `mix help deps` for more examples and options
defp deps do
[]
end
end
然后我用iex -S mix
or开始项目MIX_ENV=dev iex -S mix
,我想用 获取环境变量:application.get_env(:basic, :foo)
,它变成了:undefined
; 并使用:application.get_all_env(:basic)
,它返回[included_applications: []]
,没有env
变量。我的问题是我应该如何获得环境价值?