I just noticed that Haskell programs run via stack
do not receive environment variables from the calling environment. Here's a sample program:
-- testenv.hs
import System.Environment
main :: IO ()
main = print =<< getEnv "FOOBAR"
If I run it without stack, like this, it works:
% FOOBAR=123 runhaskell testenv.hs
"123"
But using stack:
% FOOBAR=123 stack runhaskell testenv.hs
testenv.hs: FOOBAR: getEnv: does not exist (no environment variable)
Same goes for when it is compiled: FOOBAR=123 stack exec testenv
fails while FOOBAR=123 .stack-work/install/BLAHBLAH/testenv
works.
Is there a way to force stack to pass-through certain environment variables?
The real problem I'm having is with yesod devel
, there are some settings I want to override with environment variables, but yesod devel
uses stack to run the program so they don't go through.
This is stack 1.6.5 on NixOS 18.03.132262.0a73111bc29.