Description
I believe this is a regression between Cabal 2.0 and 2.2. I discovered this when using a stack
built against Cabal 2.2. When running the command stack sdist ./some-subdir
, I got an error message about the cabal file not existing in the local directory. You can see the original report at commercialhaskell/stack#3919.
Repro I'm including Stack script headers to make it easier to test against both Cabal 2.0 (shipped with GHC 8.2.2) and Cabal 2.2 (shipped with GHC 8.4.1), but testing directly with GHC will produce the same result. Working code for GHC 8.2.2:
#!/usr/bin/env stack
-- stack --resolver ghc-8.2.2 script
import Distribution.PackageDescription.Check
import Distribution.PackageDescription.Parse
import System.Environment (getArgs)
import System.FilePath (takeDirectory)
import Distribution.PackageDescription.Configuration (flattenPackageDescription)
main :: IO ()
main = getArgs >>= mapM_ go
go :: FilePath -> IO ()
go fp = do
putStrLn $ "Checking: " ++ fp
gpd <- readGenericPackageDescription minBound fp
let dir = takeDirectory fp
pd = flattenPackageDescription gpd
checkPackageFiles pd dir >>= print
putStrLn "\n\n"
Runs with:
$ ./check-ghc-822.hs http-client/http-client/http-client.cabal
Checking: http-client/http-client/http-client.cabal
[]
Tweaked slightly to use GHC 8.4.1 instead:
#!/usr/bin/env stack
-- stack --resolver ghc-8.4.1 script
import Distribution.PackageDescription.Check
import Distribution.PackageDescription.Parsec
import System.Environment (getArgs)
import System.FilePath (takeDirectory)
import Distribution.PackageDescription.Configuration (flattenPackageDescription)
main :: IO ()
main = getArgs >>= mapM_ go
go :: FilePath -> IO ()
go fp = do
putStrLn $ "Checking: " ++ fp
gpd <- readGenericPackageDescription minBound fp
let dir = takeDirectory fp
pd = flattenPackageDescription gpd
checkPackageFiles pd dir >>= print
putStrLn "\n\n"
Results in:
$ ./check-ghc-841.hs http-client/http-client/http-client.cabal
Checking: http-client/http-client/http-client.cabal
check-ghc-841.hs: ./http-client.cabal: openBinaryFile: does not exist (No such file or directory)
However, running the script from inside the directory works fine:
$ cd http-client/http-client
$ ../../check-ghc-841.hs http-client.cabal
Checking: http-client.cabal
[]
Personally, I'd rate this as a blocker for the cabal-install 2.2 release, but perhaps the codepaths work differently there than I'm expecting.