From 861966733af7127d0bb4f5f308cf2555c6b5ee4b Mon Sep 17 00:00:00 2001 From: Tom McLaughlin Date: Sat, 2 Dec 2023 17:13:56 -0700 Subject: [PATCH] Add output about stack integration when --debug is used --- main/Main.hs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/main/Main.hs b/main/Main.hs index 2608d9db..5685d965 100644 --- a/main/Main.hs +++ b/main/Main.hs @@ -145,14 +145,19 @@ runKernel kOpts profileSrc = do Left _ -> False Right (_, stackStdout, stackStderr) -> "The Haskell Tool Stack" `isInfixOf` (stackStdout ++ stackStderr) + when debug $ putStrLn ("Using stack: " <> show stack) + -- If we're in a stack directory, use `stack` to set the environment -- We can't do this with base <= 4.6 because setEnv doesn't exist. - when stack $ - readProcess "stack" (["exec", "env"] <> stackFlags) "" >>= parseAndSetEnv + when stack $ do + when debug $ putStrLn "Using environment from stack:" + readProcess "stack" (["exec", "env"] <> stackFlags) "" >>= parseAndSetEnv debug case kernelSpecEnvFile kOpts of Nothing -> return () - Just envFile -> readFile envFile >>= parseAndSetEnv + Just envFile -> do + when debug $ putStrLn "Using environment from env file: " + readFile envFile >>= parseAndSetEnv debug -- Serve on all sockets and ports defined in the profile. interface <- serveProfile profile debug @@ -229,11 +234,13 @@ runKernel kOpts profileSrc = do isCommMessage req = mhMsgType (header req) `elem` [CommDataMessage, CommCloseMessage] - parseAndSetEnv envLines = + parseAndSetEnv debug envLines = forM_ (lines envLines) $ \line -> do case break (== '=') line of (_, []) -> return () - (key, _:val) -> setEnv key val + (key, _:val) -> do + when debug $ putStrLn ("\t" <> line) + setEnv key val -- Initial kernel state. initialKernelState :: KernelSpecOptions -> IO (MVar KernelState)