Skip to content

Improve wrapper cradle errors #2711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 14, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions exe/Wrapper.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE CPP #-}
-- | This module is based on the hie-wrapper.sh script in
-- https://github.com/alanz/vscode-hie-server
Expand Down Expand Up @@ -114,8 +115,18 @@ launchHaskellLanguageServer parsedArgs = do
callProcess e args
#else
let Cradle { cradleOptsProg = CradleAction { runGhcCmd } } = cradle
(CradleSuccess ghcBinary) <- fmap trim <$> runGhcCmd ["-v0", "-package-env=-", "-e", "putStr =<< System.Environment.getExecutablePath"]
(CradleSuccess libdir) <- HieBios.getRuntimeGhcLibDir cradle
ghcBinary <- (fmap trim <$> runGhcCmd ["-v0", "-package-env=-", "-e", "putStr =<< System.Environment.getExecutablePath"])
>>= \case
CradleSuccess ghc -> do
return ghc
CradleFail error -> die $ "Failed to get project GHC executable path:" ++ show error
CradleNone -> die "Failed get project GHC executable path, since we have a none cradle"
libdir <- HieBios.getRuntimeGhcLibDir cradle
>>= \case
CradleSuccess lib -> do
return lib
CradleFail error -> die $ "Failed to get project GHC libdir path:" ++ show error
CradleNone -> die "Failed get project GHC libdir path, since we have a none cradle"
env <- Map.fromList <$> getEnvironment
let newEnv = Map.insert "GHC_BIN" ghcBinary $ Map.insert "GHC_LIBDIR" libdir env
executeFile e True args (Just (Map.toList newEnv))
Expand Down