-
Notifications
You must be signed in to change notification settings - Fork 21
Environment variables loading with escaped quotes #20
Copy link
Copy link
Open
Labels
help wantedExtra attention is neededExtra attention is neededquestionFurther information is requestedFurther information is requestedtechnical
Description
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
| 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?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededExtra attention is neededquestionFurther information is requestedFurther information is requestedtechnical