简体   繁体   中英

How to set multiple environment variables with cabal/haskell?

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)?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM