Guess right sandbox pkg-db path on ghc version mismatch
If cabal.sandbox.config contains a "package-db:" declaration with the wrong path and only the ghc version is wrong, for example: ``` package-db: <DIR>/.cabal-sandbox/x86_64-linux-ghc-7.8.3-packages.conf.d ``` Even though the user is using 7.10.0.20141222 `cabal repl` will correct this and pass ``` -package-db <DIR>/.cabal-sandbox/x86_64-linux-ghc-7.10.0.20141222-packages.conf.d ``` to ghci, so obviously Cabal/cabal-install is doing some magic. Conflicts: Language/Haskell/GhcMod/PathsAndFiles.hs
This commit is contained in:
parent
0eaa3d23d8
commit
45d6b7d67a
@ -1,9 +1,11 @@
|
||||
{-# LANGUAGE BangPatterns, TupleSections #-}
|
||||
module Language.Haskell.GhcMod.PathsAndFiles where
|
||||
|
||||
import Config (cProjectVersion, cTargetPlatformString)
|
||||
import Control.Applicative
|
||||
import Control.Monad
|
||||
import Data.List
|
||||
import Data.List.Split (splitOn)
|
||||
import Data.Char
|
||||
import Data.Maybe
|
||||
import Data.Traversable (traverse)
|
||||
@ -92,7 +94,13 @@ getSandboxDb :: FilePath -- ^ Path to the cabal package root directory
|
||||
-> IO (Maybe FilePath)
|
||||
getSandboxDb d = do
|
||||
mConf <- traverse readFile =<< U.mightExist (d </> "cabal.sandbox.config")
|
||||
return $ extractSandboxDbDir =<< mConf
|
||||
return $ fixPkgDbVer <$> (extractSandboxDbDir =<< mConf)
|
||||
|
||||
where
|
||||
fixPkgDbVer dir =
|
||||
case takeFileName dir == ghcSandboxPkgDbDir of
|
||||
True -> dir
|
||||
False -> takeDirectory dir </> ghcSandboxPkgDbDir
|
||||
|
||||
-- | Extract the sandbox package db directory from the cabal.sandbox.config file.
|
||||
-- Exception is thrown if the sandbox config file is broken.
|
||||
@ -112,5 +120,12 @@ setupConfigFile crdl = cradleRootDir crdl </> setupConfigPath
|
||||
setupConfigPath :: FilePath
|
||||
setupConfigPath = localBuildInfoFile defaultDistPref
|
||||
|
||||
ghcSandboxPkgDbDir :: String
|
||||
ghcSandboxPkgDbDir =
|
||||
targetPlatform ++ "-ghc-" ++ cProjectVersion ++ "-packages.conf.d"
|
||||
where
|
||||
targetPlatform = display buildPlatform
|
||||
|
||||
packageCache :: String
|
||||
packageCache = "package.cache"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user