Home > Net >  How to set multiple environment variables with cabal/haskell?
How to set multiple environment variables with cabal/haskell?

Time:01-07

I am making use of postgresql-typed library which needs multiple environment variables to be set before it runs.

Right now, I am manually setting them using the shell profile script (zsh profile) before I can run any of the cabal commands like cabal build or cabal run.

But this is clumsy and doesn't work across all the platforms. Is there a idiomatic Haskell/Cabal way of doing this (For example, adding them from .env file or something)?

CodePudding user response:

As far as I know, cabal does not have a generalized tool for mucking about with environment variables. In my opinion, this is good design, of the "do one thing and do it well" variety -- there are already good external tools for setting up environment variables, some of which are quite large and complicated, and duplicating that work inside cabal is not called for.

Cabal does set a few environment variables on your behalf, but only those an external tool has no way to set properly, such as file system pointers to intermediate build products or intended installation directories.

  • Related