diff --git a/cabal-install/src/Distribution/Client/ProjectBuilding.hs b/cabal-install/src/Distribution/Client/ProjectBuilding.hs index dba81b09b17..cdf269e5bf0 100644 --- a/cabal-install/src/Distribution/Client/ProjectBuilding.hs +++ b/cabal-install/src/Distribution/Client/ProjectBuilding.hs @@ -97,6 +97,7 @@ import qualified Data.Map as Map import qualified Data.Set as Set import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy as LBS +import qualified Data.ByteString.Lazy.Char8 as LBS.Char8 import Control.Exception (Handler (..), SomeAsyncException, assert, catches, handle) import System.Directory (canonicalizePath, createDirectoryIfMissing, doesDirectoryExist, doesFileExist, removeFile, renameDirectory) @@ -1016,9 +1017,18 @@ buildAndInstallUnpackedPackage verbosity -- https://github.com/haskell/cabal/issues/4130 createDirectoryIfMissingVerbose verbosity True entryDir - LBS.writeFile - (entryDir "cabal-hash.txt") - (renderPackageHashInputs (packageHashInputs pkgshared pkg)) + let hashFileName = entryDir "cabal-hash.txt" + outPkgHashInputs = renderPackageHashInputs (packageHashInputs pkgshared pkg) + + info verbosity $ + "creating file with the inputs used to compute the package hash: " ++ hashFileName + + LBS.writeFile hashFileName outPkgHashInputs + + debug verbosity "Package hash inputs:" + traverse_ + (debug verbosity . ("> " ++)) + (lines $ LBS.Char8.unpack outPkgHashInputs) -- Ensure that there are no files in `tmpDir`, that are -- not in `entryDir`. While this breaks the diff --git a/cabal-testsuite/PackageTests/Regression/T6906/cabal.config b/cabal-testsuite/PackageTests/Regression/T6906/cabal.config new file mode 100644 index 00000000000..f32b854bbb8 --- /dev/null +++ b/cabal-testsuite/PackageTests/Regression/T6906/cabal.config @@ -0,0 +1,2 @@ +extra-include-dirs: foo +extra-lib-dirs: bar diff --git a/cabal-testsuite/PackageTests/Regression/T6906/cabal.project b/cabal-testsuite/PackageTests/Regression/T6906/cabal.project new file mode 100644 index 00000000000..e6fdbadb439 --- /dev/null +++ b/cabal-testsuite/PackageTests/Regression/T6906/cabal.project @@ -0,0 +1 @@ +packages: . diff --git a/cabal-testsuite/PackageTests/Regression/T6906/cabal.test.hs b/cabal-testsuite/PackageTests/Regression/T6906/cabal.test.hs new file mode 100644 index 00000000000..7d90659bc44 --- /dev/null +++ b/cabal-testsuite/PackageTests/Regression/T6906/cabal.test.hs @@ -0,0 +1,9 @@ +import Test.Cabal.Prelude + +main = cabalTest $ do + res <- cabalG' ["--config=cabal.config"] "v2-install" ["-v3"] + assertOutputContains "creating file with the inputs used to compute the package hash:" res + assertOutputContains "extra-lib-dirs: bar" res + expectBroken 6906 $ assertOutputDoesNotContain "extra-lib-dirs: bar bar" res + assertOutputContains "extra-include-dirs: foo" res + expectBroken 6906 $ assertOutputDoesNotContain "extra-include-dirs: foo foo" res diff --git a/cabal-testsuite/PackageTests/Regression/T6906/issue6906.cabal b/cabal-testsuite/PackageTests/Regression/T6906/issue6906.cabal new file mode 100644 index 00000000000..f5d89f2932d --- /dev/null +++ b/cabal-testsuite/PackageTests/Regression/T6906/issue6906.cabal @@ -0,0 +1,12 @@ +cabal-version: 3.0 +name: issue6906 +version: 0 +synopsis: No duplicate entries for extra-*-dirs config options in the inputs used to compute the package hash +description: When informed in the global config +author: Javier Neira +category: Tests +maintainer: atreyu.bbb@gmail.com + +executable issue6906 + build-depends: base + main-is: main.hs diff --git a/cabal-testsuite/PackageTests/Regression/T6906/main.hs b/cabal-testsuite/PackageTests/Regression/T6906/main.hs new file mode 100644 index 00000000000..3b4c8f3b856 --- /dev/null +++ b/cabal-testsuite/PackageTests/Regression/T6906/main.hs @@ -0,0 +1 @@ +main = putStrLn "Hello issue6906"