Fix 'ghcup install cabal/hls/stack --set' wrt #324
This commit is contained in:
parent
6c63a65983
commit
1f0a891bab
@ -6,6 +6,7 @@
|
|||||||
{-# LANGUAGE QuasiQuotes #-}
|
{-# LANGUAGE QuasiQuotes #-}
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
{-# LANGUAGE DuplicateRecordFields #-}
|
{-# LANGUAGE DuplicateRecordFields #-}
|
||||||
|
{-# LANGUAGE ViewPatterns #-}
|
||||||
|
|
||||||
module GHCup.OptParse.Install where
|
module GHCup.OptParse.Install where
|
||||||
|
|
||||||
@ -255,6 +256,48 @@ type InstallEffects = '[ AlreadyInstalled
|
|||||||
, NoToolVersionSet
|
, NoToolVersionSet
|
||||||
, FileAlreadyExistsError
|
, FileAlreadyExistsError
|
||||||
, ProcessError
|
, ProcessError
|
||||||
|
|
||||||
|
, (AlreadyInstalled, ())
|
||||||
|
, (UnknownArchive, ())
|
||||||
|
, (ArchiveResult, ())
|
||||||
|
, (FileDoesNotExistError, ())
|
||||||
|
, (CopyError, ())
|
||||||
|
, (NotInstalled, ())
|
||||||
|
, (DirNotEmpty, ())
|
||||||
|
, (NoDownload, ())
|
||||||
|
, (NotInstalled, ())
|
||||||
|
, (BuildFailed, ())
|
||||||
|
, (TagNotFound, ())
|
||||||
|
, (DigestError, ())
|
||||||
|
, (GPGError, ())
|
||||||
|
, (DownloadFailed, ())
|
||||||
|
, (TarDirDoesNotExist, ())
|
||||||
|
, (NextVerNotFound, ())
|
||||||
|
, (NoToolVersionSet, ())
|
||||||
|
, (FileAlreadyExistsError, ())
|
||||||
|
, (ProcessError, ())
|
||||||
|
|
||||||
|
, (AlreadyInstalled, NotInstalled)
|
||||||
|
, (UnknownArchive, NotInstalled)
|
||||||
|
, (ArchiveResult, NotInstalled)
|
||||||
|
, (FileDoesNotExistError, NotInstalled)
|
||||||
|
, (CopyError, NotInstalled)
|
||||||
|
, (NotInstalled, NotInstalled)
|
||||||
|
, (DirNotEmpty, NotInstalled)
|
||||||
|
, (NoDownload, NotInstalled)
|
||||||
|
, (NotInstalled, NotInstalled)
|
||||||
|
, (BuildFailed, NotInstalled)
|
||||||
|
, (TagNotFound, NotInstalled)
|
||||||
|
, (DigestError, NotInstalled)
|
||||||
|
, (GPGError, NotInstalled)
|
||||||
|
, (DownloadFailed, NotInstalled)
|
||||||
|
, (TarDirDoesNotExist, NotInstalled)
|
||||||
|
, (NextVerNotFound, NotInstalled)
|
||||||
|
, (NoToolVersionSet, NotInstalled)
|
||||||
|
, (FileAlreadyExistsError, NotInstalled)
|
||||||
|
, (ProcessError, NotInstalled)
|
||||||
|
|
||||||
|
, ((), NotInstalled)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -420,20 +463,22 @@ install installCommand settings getAppState' runLogger = case installCommand of
|
|||||||
s'@AppState{ dirs = Dirs{ .. } } <- liftIO getAppState'
|
s'@AppState{ dirs = Dirs{ .. } } <- liftIO getAppState'
|
||||||
(case instBindist of
|
(case instBindist of
|
||||||
Nothing -> runInstTool s' instPlatform $ do
|
Nothing -> runInstTool s' instPlatform $ do
|
||||||
(v, vi) <- liftE $ fromVersion instVer Cabal
|
(_tvVersion -> v, vi) <- liftE $ fromVersion instVer Cabal
|
||||||
liftE $ installCabalBin
|
void $ liftE $ sequenceE (installCabalBin
|
||||||
(_tvVersion v)
|
v
|
||||||
isolateDir
|
isolateDir
|
||||||
forceInstall
|
forceInstall
|
||||||
|
) $ when instSet $ void $ setCabal v
|
||||||
pure vi
|
pure vi
|
||||||
Just uri -> do
|
Just uri -> do
|
||||||
runInstTool s'{ settings = settings { noVerify = True}} instPlatform $ do
|
runInstTool s'{ settings = settings { noVerify = True}} instPlatform $ do
|
||||||
(v, vi) <- liftE $ fromVersion instVer Cabal
|
(_tvVersion -> v, vi) <- liftE $ fromVersion instVer Cabal
|
||||||
liftE $ installCabalBindist
|
void $ liftE $ sequenceE (installCabalBindist
|
||||||
(DownloadInfo uri Nothing "")
|
(DownloadInfo uri Nothing "")
|
||||||
(_tvVersion v)
|
v
|
||||||
isolateDir
|
isolateDir
|
||||||
forceInstall
|
forceInstall
|
||||||
|
) $ when instSet $ void $ setCabal v
|
||||||
pure vi
|
pure vi
|
||||||
)
|
)
|
||||||
>>= \case
|
>>= \case
|
||||||
@ -450,6 +495,14 @@ install installCommand settings getAppState' runLogger = case installCommand of
|
|||||||
runLogger $ logWarn $
|
runLogger $ logWarn $
|
||||||
"File " <> T.pack fp <> " already exists. Use 'ghcup install cabal --isolate " <> T.pack fp <> " --force ..." <> "' if you want to overwrite."
|
"File " <> T.pack fp <> " already exists. Use 'ghcup install cabal --isolate " <> T.pack fp <> " --force ..." <> "' if you want to overwrite."
|
||||||
pure $ ExitFailure 3
|
pure $ ExitFailure 3
|
||||||
|
VLeft (V (AlreadyInstalled _ v, ())) -> do
|
||||||
|
runLogger $ logWarn $
|
||||||
|
"Cabal ver " <> prettyVer v <> " already installed; if you really want to reinstall it, you may want to run 'ghcup install cabal --force " <> prettyVer v <> "'"
|
||||||
|
pure ExitSuccess
|
||||||
|
VLeft (V (FileAlreadyExistsError fp, ())) -> do
|
||||||
|
runLogger $ logWarn $
|
||||||
|
"File " <> T.pack fp <> " already exists. Use 'ghcup install cabal --isolate " <> T.pack fp <> " --force ..." <> "' if you want to overwrite."
|
||||||
|
pure $ ExitFailure 3
|
||||||
VLeft e -> do
|
VLeft e -> do
|
||||||
runLogger $ do
|
runLogger $ do
|
||||||
logError $ T.pack $ prettyShow e
|
logError $ T.pack $ prettyShow e
|
||||||
@ -461,21 +514,23 @@ install installCommand settings getAppState' runLogger = case installCommand of
|
|||||||
s'@AppState{ dirs = Dirs{ .. } } <- liftIO getAppState'
|
s'@AppState{ dirs = Dirs{ .. } } <- liftIO getAppState'
|
||||||
(case instBindist of
|
(case instBindist of
|
||||||
Nothing -> runInstTool s' instPlatform $ do
|
Nothing -> runInstTool s' instPlatform $ do
|
||||||
(v, vi) <- liftE $ fromVersion instVer HLS
|
(_tvVersion -> v, vi) <- liftE $ fromVersion instVer HLS
|
||||||
liftE $ installHLSBin
|
void $ liftE $ sequenceE (installHLSBin
|
||||||
(_tvVersion v)
|
v
|
||||||
isolateDir
|
isolateDir
|
||||||
forceInstall
|
forceInstall
|
||||||
|
) $ when instSet $ void $ setHLS v SetHLSOnly Nothing
|
||||||
pure vi
|
pure vi
|
||||||
Just uri -> do
|
Just uri -> do
|
||||||
runInstTool s'{ settings = settings { noVerify = True}} instPlatform $ do
|
runInstTool s'{ settings = settings { noVerify = True}} instPlatform $ do
|
||||||
(v, vi) <- liftE $ fromVersion instVer HLS
|
(_tvVersion -> v, vi) <- liftE $ fromVersion instVer HLS
|
||||||
-- TODO: support legacy
|
-- TODO: support legacy
|
||||||
liftE $ installHLSBindist
|
void $ liftE $ sequenceE (installHLSBindist
|
||||||
(DownloadInfo uri (Just $ RegexDir "haskell-language-server-*") "")
|
(DownloadInfo uri (Just $ RegexDir "haskell-language-server-*") "")
|
||||||
(_tvVersion v)
|
v
|
||||||
isolateDir
|
isolateDir
|
||||||
forceInstall
|
forceInstall
|
||||||
|
) $ when instSet $ void $ setHLS v SetHLSOnly Nothing
|
||||||
pure vi
|
pure vi
|
||||||
)
|
)
|
||||||
>>= \case
|
>>= \case
|
||||||
@ -496,6 +551,18 @@ install installCommand settings getAppState' runLogger = case installCommand of
|
|||||||
runLogger $ logWarn $
|
runLogger $ logWarn $
|
||||||
"File " <> T.pack fp <> " already exists. Use 'ghcup install hls --isolate " <> T.pack fp <> " --force ..." <> "' if you want to overwrite."
|
"File " <> T.pack fp <> " already exists. Use 'ghcup install hls --isolate " <> T.pack fp <> " --force ..." <> "' if you want to overwrite."
|
||||||
pure $ ExitFailure 3
|
pure $ ExitFailure 3
|
||||||
|
VLeft (V (AlreadyInstalled _ v, ())) -> do
|
||||||
|
runLogger $ logWarn $
|
||||||
|
"HLS ver "
|
||||||
|
<> prettyVer v
|
||||||
|
<> " already installed; if you really want to reinstall it, you may want to run 'ghcup install hls --force "
|
||||||
|
<> prettyVer v
|
||||||
|
<> "'"
|
||||||
|
pure ExitSuccess
|
||||||
|
VLeft (V (FileAlreadyExistsError fp, ())) -> do
|
||||||
|
runLogger $ logWarn $
|
||||||
|
"File " <> T.pack fp <> " already exists. Use 'ghcup install hls --isolate " <> T.pack fp <> " --force ..." <> "' if you want to overwrite."
|
||||||
|
pure $ ExitFailure 3
|
||||||
VLeft e -> do
|
VLeft e -> do
|
||||||
runLogger $ do
|
runLogger $ do
|
||||||
logError $ T.pack $ prettyShow e
|
logError $ T.pack $ prettyShow e
|
||||||
@ -507,20 +574,22 @@ install installCommand settings getAppState' runLogger = case installCommand of
|
|||||||
s'@AppState{ dirs = Dirs{ .. } } <- liftIO getAppState'
|
s'@AppState{ dirs = Dirs{ .. } } <- liftIO getAppState'
|
||||||
(case instBindist of
|
(case instBindist of
|
||||||
Nothing -> runInstTool s' instPlatform $ do
|
Nothing -> runInstTool s' instPlatform $ do
|
||||||
(v, vi) <- liftE $ fromVersion instVer Stack
|
(_tvVersion -> v, vi) <- liftE $ fromVersion instVer Stack
|
||||||
liftE $ installStackBin
|
void $ liftE $ sequenceE (installStackBin
|
||||||
(_tvVersion v)
|
v
|
||||||
isolateDir
|
isolateDir
|
||||||
forceInstall
|
forceInstall
|
||||||
|
) $ when instSet $ void $ setStack v
|
||||||
pure vi
|
pure vi
|
||||||
Just uri -> do
|
Just uri -> do
|
||||||
runInstTool s'{ settings = settings { noVerify = True}} instPlatform $ do
|
runInstTool s'{ settings = settings { noVerify = True}} instPlatform $ do
|
||||||
(v, vi) <- liftE $ fromVersion instVer Stack
|
(_tvVersion -> v, vi) <- liftE $ fromVersion instVer Stack
|
||||||
liftE $ installStackBindist
|
void $ liftE $ sequenceE (installStackBindist
|
||||||
(DownloadInfo uri Nothing "")
|
(DownloadInfo uri Nothing "")
|
||||||
(_tvVersion v)
|
v
|
||||||
isolateDir
|
isolateDir
|
||||||
forceInstall
|
forceInstall
|
||||||
|
) $ when instSet $ void $ setStack v
|
||||||
pure vi
|
pure vi
|
||||||
)
|
)
|
||||||
>>= \case
|
>>= \case
|
||||||
@ -537,6 +606,14 @@ install installCommand settings getAppState' runLogger = case installCommand of
|
|||||||
runLogger $ logWarn $
|
runLogger $ logWarn $
|
||||||
"File " <> T.pack fp <> " already exists. Use 'ghcup install stack --isolate " <> T.pack fp <> " --force ..." <> "' if you want to overwrite."
|
"File " <> T.pack fp <> " already exists. Use 'ghcup install stack --isolate " <> T.pack fp <> " --force ..." <> "' if you want to overwrite."
|
||||||
pure $ ExitFailure 3
|
pure $ ExitFailure 3
|
||||||
|
VLeft (V (AlreadyInstalled _ v, ())) -> do
|
||||||
|
runLogger $ logWarn $
|
||||||
|
"Stack ver " <> prettyVer v <> " already installed; if you really want to reinstall it, you may want to run 'ghcup install stack --force " <> prettyVer v <> "'"
|
||||||
|
pure ExitSuccess
|
||||||
|
VLeft (V (FileAlreadyExistsError fp, ())) -> do
|
||||||
|
runLogger $ logWarn $
|
||||||
|
"File " <> T.pack fp <> " already exists. Use 'ghcup install stack --isolate " <> T.pack fp <> " --force ..." <> "' if you want to overwrite."
|
||||||
|
pure $ ExitFailure 3
|
||||||
VLeft e -> do
|
VLeft e -> do
|
||||||
runLogger $ do
|
runLogger $ do
|
||||||
logError $ T.pack $ prettyShow e
|
logError $ T.pack $ prettyShow e
|
||||||
|
Loading…
Reference in New Issue
Block a user