Skip to content

Running parse should not mutate the environment #9

@pbrisbin

Description

@pbrisbin

Sample code:

loadConfig :: IO String
loadConfig = Env.parse id $ Env.var Env.str "STR" mempty

main :: IO ()
main = do
    print =<< loadConfig
    print =<< loadConfig

Expected outcome

% stack build && STR=str stack exec example
"str"
"str"

Actual outcome:

% stack build && STR=str stack exec example
"str"
Available environment variables:

  STR

Parsing errors:

  STR is unset

This is breaking things for me because my app loads configuration from the environment at startup, and we load a new App value for each of our test cases. So the first test case reads the environment, unsets everything, then subsequent test cases fail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions