Firstly, thank you so much for this amazing resource!
Onto the issue. When I insert this code:
|
try do # wrap in "try do" |
|
File.stream!("./.env") # in case .env file does not exist. |
|
|> Stream.map(&String.trim_trailing/1) # remove excess whitespace |
|
|> Enum.each(fn line -> line # loop through each line |
|
|> String.replace("export ", "") # remove "export" from line |
|
|> String.split("=", parts: 2) # split on *first* "=" (equals sign) |
|
|> Enum.reduce(fn(value, key) -> # stackoverflow.com/q/33055834/1148249 |
|
System.put_env(key, value) # set each environment variable |
|
end) |
|
end) |
|
rescue |
|
_ -> IO.puts "no .env file found!" |
|
end |
and have (double/single) quotes around the values in the .env file, the environment variables are loaded with the quotes.
For example, in the .env file:
export SOME_ENV_VAR="randomString"
results in:
iex(3)> System.get_env("SOME_ENV_VAR")
"\"randomString\""
I'm not entirely sure why there's code to load the environment variables like this. Why not just do the standard source .env?
Firstly, thank you so much for this amazing resource!
Onto the issue. When I insert this code:
phoenix-ecto-encryption-example/config/config.exs
Lines 30 to 42 in 6d79f25
and have (double/single) quotes around the values in the
.envfile, the environment variables are loaded with the quotes.For example, in the
.envfile:export SOME_ENV_VAR="randomString"results in:
I'm not entirely sure why there's code to load the environment variables like this. Why not just do the standard
source .env?