Skip to content
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

checkPackageFiles does not work for subdirs in Cabal 2.2 #5206

Closed
snoyberg opened this issue Mar 13, 2018 · 5 comments
Closed

checkPackageFiles does not work for subdirs in Cabal 2.2 #5206

snoyberg opened this issue Mar 13, 2018 · 5 comments

Comments

@snoyberg
Copy link
Collaborator

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.

@hvr
Copy link
Member

hvr commented Mar 13, 2018

Can this also be reproduced w/o Stack? If so I'd appreciate repro instructions in that spirit.

@snoyberg
Copy link
Collaborator Author

Yes, it's reproducible with just runghc on the file.

@snoyberg
Copy link
Collaborator Author

Turned out to be a simple fix of adding a relative call. PR opened at #5208.

It looks like the regression was introduced in 96bcbf1.

@hvr
Copy link
Member

hvr commented Mar 13, 2018

wow... that one went undetected for a very long time...

23Skidoo added a commit that referenced this issue Mar 27, 2018
Add missing relative for getFileContents #5206
23Skidoo pushed a commit that referenced this issue Mar 27, 2018
@23Skidoo
Copy link
Member

23Skidoo commented Mar 30, 2018

This was fixed by #5208, both in master and 2.2. Fix is included in Cabal-2.2.0.1 onwards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants