Skip to content

Commit 511527c

Browse files
committed
Probe-tools: Print stack ghc version
The ghc version on the $PATH is often not relevant for stack projects. The ghc version stack is using is printed in addition.
1 parent 0e74593 commit 511527c

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/Ide/Version.hs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ hlsVersion =
3838
hlsGhcDisplayVersion = compilerName ++ "-" ++ VERSION_ghc
3939

4040
data ProgramsOfInterest = ProgramsOfInterest
41-
{ cabalVersion :: Maybe Version
42-
, stackVersion :: Maybe Version
43-
, ghcVersion :: Maybe Version
41+
{ cabalVersion :: Maybe Version
42+
, stackVersion :: Maybe Version
43+
, ghcVersion :: Maybe Version
44+
, stackGhcVersion :: Maybe Version
4445
}
4546

4647
showProgramVersionOfInterest :: ProgramsOfInterest -> String
@@ -49,26 +50,27 @@ showProgramVersionOfInterest ProgramsOfInterest {..} =
4950
[ "cabal:\t\t" ++ showVersionWithDefault cabalVersion
5051
, "stack:\t\t" ++ showVersionWithDefault stackVersion
5152
, "ghc:\t\t" ++ showVersionWithDefault ghcVersion
53+
, "stack ghc:\t" ++ showVersionWithDefault stackGhcVersion
5254
]
5355
where
5456
showVersionWithDefault :: Maybe Version -> String
5557
showVersionWithDefault = maybe "Not found" showVersion
5658

5759
findProgramVersions :: IO ProgramsOfInterest
5860
findProgramVersions = ProgramsOfInterest
59-
<$> findVersionOf "cabal"
60-
<*> findVersionOf "stack"
61-
<*> findVersionOf "ghc"
61+
<$> findVersionOf "cabal" ["--numeric-version"]
62+
<*> findVersionOf "stack" ["--numeric-version"]
63+
<*> findVersionOf "ghc" ["--numeric-version"]
64+
<*> findVersionOf "stack" ["ghc", "--", "--numeric-version"]
6265

6366
-- | Find the version of the given program.
64-
-- Assumes the program accepts the cli argument "--numeric-version".
6567
-- If the invocation has a non-zero exit-code, we return 'Nothing'
66-
findVersionOf :: FilePath -> IO (Maybe Version)
67-
findVersionOf tool =
68+
findVersionOf :: FilePath -> [String] -> IO (Maybe Version)
69+
findVersionOf tool args =
6870
findExecutable tool >>= \case
6971
Nothing -> pure Nothing
7072
Just path ->
71-
readProcessWithExitCode path ["--numeric-version"] "" >>= \case
73+
readProcessWithExitCode path args "" >>= \case
7274
(ExitSuccess, sout, _) -> pure $ consumeParser myVersionParser sout
7375
_ -> pure Nothing
7476
where

0 commit comments

Comments
 (0)