From 1cc99f7a25fd45730d8542d36b44ef1eeae6dea4 Mon Sep 17 00:00:00 2001 From: SuganyaAK Date: Sun, 6 Aug 2023 18:50:25 -0400 Subject: [PATCH 01/16] Cabal Package Exceptions --- Cabal/src/Distribution/Simple.hs | 13 +- Cabal/src/Distribution/Simple/Build.hs | 5 +- Cabal/src/Distribution/Simple/Configure.hs | 281 ++++------------- Cabal/src/Distribution/Simple/Errors.hs | 300 ++++++++++++++++++- Cabal/src/Distribution/Simple/Program/Run.hs | 14 +- 5 files changed, 374 insertions(+), 239 deletions(-) diff --git a/Cabal/src/Distribution/Simple.hs b/Cabal/src/Distribution/Simple.hs index 10b1c9fb50e..d6f50d0af90 100644 --- a/Cabal/src/Distribution/Simple.hs +++ b/Cabal/src/Distribution/Simple.hs @@ -92,6 +92,7 @@ import Distribution.Pretty import Distribution.Simple.Bench import Distribution.Simple.BuildPaths import Distribution.Simple.ConfigureScript +import Distribution.Simple.Errors import Distribution.Simple.Haddock import Distribution.Simple.Install import Distribution.Simple.LocalBuildInfo @@ -601,16 +602,10 @@ sanityCheckHookedBuildInfo verbosity (PackageDescription{library = Nothing}) (Just _, _) = - die' verbosity $ - "The buildinfo contains info for a library, " - ++ "but the package does not have a library." + dieWithException verbosity $ NoLibraryForPackage sanityCheckHookedBuildInfo verbosity pkg_descr (_, hookExes) | exe1 : _ <- nonExistant = - die' verbosity $ - "The buildinfo contains info for an executable called '" - ++ prettyShow exe1 - ++ "' but the package does not have a " - ++ "executable with that name." + dieWithException verbosity $ SanityCheckHookedBuildInfo exe1 where pkgExeNames = nub (map exeName (executables pkg_descr)) hookExeNames = nub (map fst hookExes) @@ -777,7 +772,7 @@ autoconfUserHooks = verbosity flags lbi - else die' verbosity "configure script not found." + else dieWithException verbosity ConfigureScriptNotFound pbi <- getHookedBuildInfo verbosity (buildDir lbi) sanityCheckHookedBuildInfo verbosity pkg_descr pbi diff --git a/Cabal/src/Distribution/Simple/Build.hs b/Cabal/src/Distribution/Simple/Build.hs index 6d9aa5b3486..c5633c159d2 100644 --- a/Cabal/src/Distribution/Simple/Build.hs +++ b/Cabal/src/Distribution/Simple/Build.hs @@ -181,9 +181,8 @@ checkSemaphoreSupport :: Verbosity -> Compiler -> BuildFlags -> IO () checkSemaphoreSupport verbosity comp flags = do unless (jsemSupported comp || (isNothing (flagToMaybe (buildUseSemaphore flags)))) $ - die' verbosity $ - "Your compiler does not support the -jsem flag. " - ++ "To use this feature you must use GHC 9.8 or later." + dieWithException verbosity $ + CheckSemaphoreSupport -- | Write available build information for 'LocalBuildInfo' to disk. -- diff --git a/Cabal/src/Distribution/Simple/Configure.hs b/Cabal/src/Distribution/Simple/Configure.hs index 9298ab0d763..29de051b3ea 100644 --- a/Cabal/src/Distribution/Simple/Configure.hs +++ b/Cabal/src/Distribution/Simple/Configure.hs @@ -150,14 +150,9 @@ import qualified System.Info import Text.PrettyPrint ( Doc , char - , comma , hsep - , nest - , punctuate , quotes - , render , renderStyle - , sep , text , ($+$) ) @@ -165,6 +160,7 @@ import Text.PrettyPrint import qualified Data.Maybe as M import qualified Data.Set as Set import qualified Distribution.Compat.NonEmptySet as NES +import Distribution.Simple.Errors import Distribution.Types.AnnotatedId type UseExternalInternalDeps = Bool @@ -425,11 +421,11 @@ configure (pkg_descr0, pbi) cfg = do case targets' of _ | null (configArgs cfg) -> return Nothing [cname] -> return (Just cname) - [] -> die' verbosity "No valid component targets found" + [] -> dieWithException verbosity NoValidComponent _ -> - die' + dieWithException verbosity - "Can only configure either single component or all of them" + ConfigureEitherSingleOrAll let use_external_internal_deps = isJust mb_cname case mb_cname of @@ -444,7 +440,7 @@ configure (pkg_descr0, pbi) cfg = do -- configCID is only valid for per-component configure when (isJust (flagToMaybe (configCID cfg)) && isNothing mb_cname) $ - die' verbosity "--cid is only supported for per-component configure" + dieWithException verbosity ConfigCIDValidForPreComponent checkDeprecatedFlags verbosity cfg checkExactConfiguration verbosity pkg_descr0 cfg @@ -513,15 +509,12 @@ configure (pkg_descr0, pbi) cfg = do ( isJust mb_cname && (fromFlag (configTests cfg) || fromFlag (configBenchmarks cfg)) ) - $ die' verbosity - $ "--enable-tests/--enable-benchmarks are incompatible with" - ++ " explicitly specifying a component to configure." + $ dieWithException verbosity SanitycheckForEnableComponents -- Some sanity checks related to dynamic/static linking. when (fromFlag (configDynExe cfg) && fromFlag (configFullyStaticExe cfg)) $ - die' verbosity $ - "--enable-executable-dynamic and --enable-executable-static" - ++ " are incompatible with each other." + dieWithException verbosity $ + SanityCheckForDynamicStaticLinking -- allConstraints: The set of all 'Dependency's we have. Used ONLY -- to 'configureFinalizedPackage'. @@ -539,7 +532,7 @@ configure (pkg_descr0, pbi) cfg = do ( allConstraints :: [PackageVersionConstraint] , requiredDepsMap :: Map (PackageName, ComponentName) InstalledPackageInfo ) <- - either (die' verbosity) return $ + either (dieWithException verbosity) return $ combinedConstraints (configConstraints cfg) (configDependencies cfg) @@ -657,14 +650,8 @@ configure (pkg_descr0, pbi) cfg = do (enabledBuildInfos pkg_descr enabled) let langs = unsupportedLanguages comp langlist when (not (null langs)) $ - die' verbosity $ - "The package " - ++ prettyShow (packageId pkg_descr0) - ++ " requires the following languages which are not " - ++ "supported by " - ++ prettyShow (compilerId comp) - ++ ": " - ++ intercalate ", " (map prettyShow langs) + dieWithException verbosity $ + UnsupportedLanguages (packageId pkg_descr0) (compilerId comp) (map prettyShow langs) let extlist = nub $ concatMap @@ -672,22 +659,15 @@ configure (pkg_descr0, pbi) cfg = do (enabledBuildInfos pkg_descr enabled) let exts = unsupportedExtensions comp extlist when (not (null exts)) $ - die' verbosity $ - "The package " - ++ prettyShow (packageId pkg_descr0) - ++ " requires the following language extensions which are not " - ++ "supported by " - ++ prettyShow (compilerId comp) - ++ ": " - ++ intercalate ", " (map prettyShow exts) + dieWithException verbosity $ + UnsupportedLanguageExtension (packageId pkg_descr0) (compilerId comp) (map prettyShow exts) -- Check foreign library build requirements let flibs = [flib | CFLib flib <- enabledComponents pkg_descr enabled] let unsupportedFLibs = unsupportedForeignLibs comp compPlatform flibs when (not (null unsupportedFLibs)) $ - die' verbosity $ - "Cannot build some foreign libraries: " - ++ intercalate "," unsupportedFLibs + dieWithException verbosity $ + CantFindForeignLibraries unsupportedFLibs -- Configure certain external build tools, see below for which ones. let requiredBuildTools = do @@ -968,8 +948,8 @@ configure (pkg_descr0, pbi) cfg = do ( isAbsolute (prefix dirs) || "${pkgroot}" `isPrefixOf` prefix dirs ) - $ die' verbosity - $ "expected an absolute directory name for --prefix: " ++ prefix dirs + $ dieWithException verbosity + $ ExpectedAbsoluteDirectory (prefix dirs) when ("${pkgroot}" `isPrefixOf` prefix dirs) $ warn verbosity $ @@ -1084,10 +1064,8 @@ checkExactConfiguration verbosity pkg_descr0 cfg = allFlags = map flagName . genPackageFlags $ pkg_descr0 diffFlags = allFlags \\ cmdlineFlags when (not . null $ diffFlags) $ - die' verbosity $ - "'--exact-configuration' was given, " - ++ "but the following flags were not specified: " - ++ intercalate ", " (map show diffFlags) + dieWithException verbosity $ + FlagsNotSpecified diffFlags -- | Create a PackageIndex that makes *any libraries that might be* -- defined internally to this package look like installed packages, in @@ -1246,15 +1224,7 @@ configureFinalizedPackage pkg_descr0 of Right r -> return r Left missing -> - die' verbosity $ - "Encountered missing or private dependencies:\n" - ++ ( render - . nest 4 - . sep - . punctuate comma - . map (pretty . simplifyDependency) - $ missing - ) + dieWithException verbosity $ EncounteredMissingDependency missing -- add extra include/lib dirs as specified in cfg -- we do it here so that those get checked too @@ -1328,26 +1298,20 @@ checkCompilerProblems verbosity comp pkg_descr enabled = do (all (isDefaultIncludeRenaming . mixinIncludeRenaming) . mixins) (enabledBuildInfos pkg_descr enabled) ) - $ die' verbosity - $ "Your compiler does not support thinning and renaming on " - ++ "package flags. To use this feature you must use " - ++ "GHC 7.9 or later." - + $ dieWithException verbosity + $ CompilerDoesntSupportThinning when ( any (not . null . reexportedModules) (allLibraries pkg_descr) && not (reexportedModulesSupported comp) ) - $ die' verbosity - $ "Your compiler does not support module re-exports. To use " - ++ "this feature you must use GHC 7.9 or later." - + $ dieWithException verbosity + $ CompilerDoesntSupportReexports when ( any (not . null . signatures) (allLibraries pkg_descr) && not (backpackSupported comp) ) - $ die' verbosity - $ "Your compiler does not support Backpack. To use " - ++ "this feature you must use GHC 8.1 or later." + $ dieWithException verbosity + $ CompilerDoesntSupportBackpack -- | Select dependencies for the package. configureDependencies @@ -1410,13 +1374,8 @@ configureDependencies ( not (null internalPkgDeps) && not (newPackageDepsBehaviour pkg_descr) ) - $ die' verbosity - $ "The field 'build-depends: " - ++ intercalate ", " (map (prettyShow . packageName) internalPkgDeps) - ++ "' refers to a library which is defined within the same " - ++ "package. To use this feature the package must specify at " - ++ "least 'cabal-version: >= 1.8'." - + $ dieWithException verbosity + $ LibraryWithinSamePackage internalPkgDeps reportFailedDependencies verbosity failedDeps reportSelectedDependencies verbosity allPkgDeps @@ -1605,10 +1564,10 @@ data DependencyResolution -- polymorphism out of the 'Package' typeclass.) InternalDependency PackageId -data FailedDependency - = DependencyNotExists PackageName - | DependencyMissingInternal PackageName LibraryName - | DependencyNoVersion Dependency +-- data FailedDependency +-- = DependencyNotExists PackageName +-- | DependencyMissingInternal PackageName LibraryName +-- | DependencyNoVersion Dependency -- | Test for a package dependency and record the version we have installed. selectDependency @@ -1718,26 +1677,7 @@ reportSelectedDependencies verbosity deps = reportFailedDependencies :: Verbosity -> [FailedDependency] -> IO () reportFailedDependencies _ [] = return () reportFailedDependencies verbosity failed = - die' verbosity (intercalate "\n\n" (map reportFailedDependency failed)) - where - reportFailedDependency (DependencyNotExists pkgname) = - "there is no version of " - ++ prettyShow pkgname - ++ " installed.\n" - ++ "Perhaps you need to download and install it from\n" - ++ hackageUrl - ++ prettyShow pkgname - ++ "?" - reportFailedDependency (DependencyMissingInternal pkgname lib) = - "internal dependency " - ++ prettyShow (prettyLibraryNameComponent lib) - ++ " not installed.\n" - ++ "Perhaps you need to configure and install it first?\n" - ++ "(This library was defined by " - ++ prettyShow pkgname - ++ ")" - reportFailedDependency (DependencyNoVersion dep) = - "cannot satisfy dependency " ++ prettyShow (simplifyDependency dep) ++ "\n" + dieWithException verbosity $ ReportFailedDependencies failed hackageUrl -- | List all installed packages in the given package databases. -- Non-existent package databases do not cause errors, they just get skipped @@ -1752,10 +1692,8 @@ getInstalledPackages -> IO InstalledPackageIndex getInstalledPackages verbosity comp packageDBs progdb = do when (null packageDBs) $ - die' verbosity $ - "No package databases have been specified. If you use " - ++ "--package-db=clear, you must follow it with --package-db= " - ++ "with 'global', 'user' or a specific file." + dieWithException verbosity $ + NoPackageDatabaseSpecified info verbosity "Reading installed packages..." -- do not check empty packagedbs (ghc-pkg would error out) @@ -1767,9 +1705,7 @@ getInstalledPackages verbosity comp packageDBs progdb = do HaskellSuite{} -> HaskellSuite.getInstalledPackages verbosity packageDBs' progdb flv -> - die' verbosity $ - "don't know how to find the installed packages for " - ++ prettyShow flv + dieWithException verbosity $ HowToFindInstalledPackages flv where packageDBExists (SpecificPackageDB path) = do exists <- doesPathExist path @@ -1859,17 +1795,18 @@ combinedConstraints -- ^ installed dependencies -> InstalledPackageIndex -> Either - String + CabalException ( [PackageVersionConstraint] , Map (PackageName, ComponentName) InstalledPackageInfo ) combinedConstraints constraints dependencies installedPackages = do when (not (null badComponentIds)) $ Left $ - render $ - text "The following package dependencies were requested" - $+$ nest 4 (dispDependencies badComponentIds) - $+$ text "however the given installed package instance does not exist." + CombinedConstraints (dispDependencies badComponentIds) + -- (render $ + -- text "The following package dependencies were requested" + -- $+$ nest 4 (dispDependencies badComponentIds) + -- $+$ text "however the given installed package instance does not exist." ) -- TODO: we don't check that all dependencies are used! @@ -2045,28 +1982,14 @@ configurePkgconfigPackages verbosity pkg_descr progdb enabled requirePkg dep@(PkgconfigDependency pkgn range) = do version <- pkgconfig ["--modversion", pkg] - `catchIO` (\_ -> die' verbosity notFound) - `catchExit` (\_ -> die' verbosity notFound) + `catchIO` (\_ -> dieWithException verbosity $ PkgConfigNotFound pkg versionRequirement) + `catchExit` (\_ -> dieWithException verbosity $ PkgConfigNotFound pkg versionRequirement) let trim = dropWhile isSpace . dropWhileEnd isSpace let v = PkgconfigVersion (toUTF8BS $ trim version) if not (withinPkgconfigVersionRange v range) - then die' verbosity (badVersion v) + then dieWithException verbosity $ BadVersion pkg versionRequirement v else info verbosity (depSatisfied v) where - notFound = - "The pkg-config package '" - ++ pkg - ++ "'" - ++ versionRequirement - ++ " is required but it could not be found." - badVersion v = - "The pkg-config package '" - ++ pkg - ++ "'" - ++ versionRequirement - ++ " is required but the version installed on the" - ++ " system is version " - ++ prettyShow v depSatisfied v = "Dependency " ++ prettyShow dep @@ -2159,14 +2082,14 @@ configCompilerEx -> ProgramDb -> Verbosity -> IO (Compiler, Platform, ProgramDb) -configCompilerEx Nothing _ _ _ verbosity = die' verbosity "Unknown compiler" +configCompilerEx Nothing _ _ _ verbosity = dieWithException verbosity UnknownCompilerException configCompilerEx (Just hcFlavor) hcPath hcPkg progdb verbosity = do (comp, maybePlatform, programDb) <- case hcFlavor of GHC -> GHC.configure verbosity hcPath hcPkg progdb GHCJS -> GHCJS.configure verbosity hcPath hcPkg progdb UHC -> UHC.configure verbosity hcPath hcPkg progdb HaskellSuite{} -> HaskellSuite.configure verbosity hcPath hcPkg progdb - _ -> die' verbosity "Unknown compiler" + _ -> dieWithException verbosity UnknownCompilerException return (comp, fromMaybe buildPlatform maybePlatform, programDb) -- ----------------------------------------------------------------------------- @@ -2370,80 +2293,9 @@ checkForeignDeps pkg lbi verbosity = explainErrors Nothing [] = return () -- should be impossible! explainErrors _ _ | isNothing . lookupProgram gccProgram . withPrograms $ lbi = - die' verbosity $ - unlines - [ "No working gcc" - , "This package depends on foreign library but we cannot " - ++ "find a working C compiler. If you have it in a " - ++ "non-standard location you can use the --with-gcc " - ++ "flag to specify it." - ] + dieWithException verbosity $ NoWorkingGcc explainErrors hdr libs = - die' verbosity $ - unlines $ - [ if plural - then "Missing dependencies on foreign libraries:" - else "Missing dependency on a foreign library:" - | missing - ] - ++ case hdr of - Just (Left h) -> ["* Missing (or bad) header file: " ++ h] - _ -> [] - ++ case libs of - [] -> [] - [lib] -> ["* Missing (or bad) C library: " ++ lib] - _ -> - [ "* Missing (or bad) C libraries: " - ++ intercalate ", " libs - ] - ++ [if plural then messagePlural else messageSingular | missing] - ++ case hdr of - Just (Left _) -> [headerCppMessage] - Just (Right h) -> - [ (if missing then "* " else "") - ++ "Bad header file: " - ++ h - , headerCcMessage - ] - _ -> [] - where - plural = length libs >= 2 - -- Is there something missing? (as opposed to broken) - missing = - not (null libs) - || case hdr of Just (Left _) -> True; _ -> False - - messageSingular = - "This problem can usually be solved by installing the system " - ++ "package that provides this library (you may need the " - ++ "\"-dev\" version). If the library is already installed " - ++ "but in a non-standard location then you can use the flags " - ++ "--extra-include-dirs= and --extra-lib-dirs= to specify " - ++ "where it is." - ++ "If the library file does exist, it may contain errors that " - ++ "are caught by the C compiler at the preprocessing stage. " - ++ "In this case you can re-run configure with the verbosity " - ++ "flag -v3 to see the error messages." - messagePlural = - "This problem can usually be solved by installing the system " - ++ "packages that provide these libraries (you may need the " - ++ "\"-dev\" versions). If the libraries are already installed " - ++ "but in a non-standard location then you can use the flags " - ++ "--extra-include-dirs= and --extra-lib-dirs= to specify " - ++ "where they are." - ++ "If the library files do exist, it may contain errors that " - ++ "are caught by the C compiler at the preprocessing stage. " - ++ "In this case you can re-run configure with the verbosity " - ++ "flag -v3 to see the error messages." - headerCppMessage = - "If the header file does exist, it may contain errors that " - ++ "are caught by the C compiler at the preprocessing stage. " - ++ "In this case you can re-run configure with the verbosity " - ++ "flag -v3 to see the error messages." - headerCcMessage = - "The header file contains a compile error. " - ++ "You can re-run configure with the verbosity flag " - ++ "-v3 to see the error messages from the C compiler." + dieWithException verbosity $ ExplainErrors hdr libs -- | Output package check warnings and errors. Exit if any errors. checkPackageProblems @@ -2460,7 +2312,7 @@ checkPackageProblems verbosity dir gpkg pkg = do partitionEithers (M.mapMaybe classEW $ pureChecks ++ ioChecks) if null errors then traverse_ (warn verbosity) (map ppPackageCheck warnings) - else die' verbosity (intercalate "\n\n" $ map ppPackageCheck errors) + else dieWithException verbosity $ CheckPackageProblems (map ppPackageCheck errors) where -- Classify error/warnings. Left: error, Right: warning. classEW :: PackageCheck -> Maybe (Either PackageCheck PackageCheck) @@ -2491,29 +2343,24 @@ checkRelocatable verbosity pkg lbi = -- Distribution.Simple.GHC.getRPaths checkOS = unless (os `elem` [OSX, Linux]) $ - die' verbosity $ - "Operating system: " - ++ prettyShow os - ++ ", does not support relocatable builds" + dieWithException verbosity $ + NoOSSupport os where (Platform _ os) = hostPlatform lbi -- Check if the Compiler support relocatable builds checkCompiler = unless (compilerFlavor comp `elem` [GHC]) $ - die' verbosity $ - "Compiler: " - ++ show comp - ++ ", does not support relocatable builds" + dieWithException verbosity $ + NoCompilerSupport (show comp) where comp = compiler lbi -- Check if all the install dirs are relative to same prefix packagePrefixRelative = unless (relativeInstallDirs installDirs) $ - die' verbosity $ - "Installation directories are not prefix_relative:\n" - ++ show installDirs + dieWithException verbosity $ + InstallDirsNotPrefixRelative (installDirs) where -- NB: should be good enough to check this against the default -- component ID, but if we wanted to be strictly correct we'd @@ -2554,8 +2401,9 @@ checkRelocatable verbosity pkg lbi = -- @..@s and following check will fail without @canonicalizePath@. canonicalized <- canonicalizePath libdir unless (p `isPrefixOf` canonicalized) $ - die' verbosity $ - msg libdir + dieWithException verbosity $ + LibDirDepsPrefixNotRelative libdir p + -- msg libdir | otherwise = return () -- NB: should be good enough to check this against the default @@ -2564,11 +2412,12 @@ checkRelocatable verbosity pkg lbi = installDirs = absoluteInstallDirs pkg lbi NoCopyDest p = prefix installDirs ipkgs = PackageIndex.allPackages (installedPkgs lbi) - msg l = - "Library directory of a dependency: " - ++ show l - ++ "\nis not relative to the installation prefix:\n" - ++ show p + +{- msg l = + "Library directory of a dependency: " + ++ show l + ++ "\nis not relative to the installation prefix:\n" + ++ show p-} -- ----------------------------------------------------------------------------- -- Testing foreign library requirements diff --git a/Cabal/src/Distribution/Simple/Errors.hs b/Cabal/src/Distribution/Simple/Errors.hs index e086bf04cc3..c643bb8b0b4 100644 --- a/Cabal/src/Distribution/Simple/Errors.hs +++ b/Cabal/src/Distribution/Simple/Errors.hs @@ -11,6 +11,7 @@ module Distribution.Simple.Errors ( CabalException (..) + , FailedDependency (..) , exceptionCode , exceptionMessage ) where @@ -19,14 +20,26 @@ import Distribution.Compat.Prelude import Distribution.Compiler import Distribution.InstalledPackageInfo import Distribution.ModuleName +import Distribution.Package +import Distribution.PackageDescription (FlagName, UnqualComponentName) import Distribution.Pretty - ( prettyShow + ( Pretty (pretty) + , prettyShow ) +import Distribution.Simple.InstallDirs +import Distribution.System (OS) import Distribution.Types.BenchmarkType -import Distribution.Types.PackageId +import Distribution.Types.LibraryName +import Distribution.Types.PkgconfigVersion import Distribution.Types.TestType -import Distribution.Types.UnitId import Distribution.Version +import Text.PrettyPrint + +data FailedDependency + = DependencyNotExists PackageName + | DependencyMissingInternal PackageName LibraryName + | DependencyNoVersion Dependency + deriving (Show) -- Types representing exceptions thrown by functions in all the modules of Cabal Package data CabalException @@ -95,6 +108,42 @@ data CabalException | NoSupportPreProcessingTestExtras TestType | NoSupportPreProcessingBenchmarkExtras BenchmarkType | UnlitException String + | RunProgramInvocationException FilePath String + | GetProgamInvocationException FilePath String + | GetProgramInvocationLBSException FilePath String + | CheckSemaphoreSupport + | NoLibraryForPackage + | SanityCheckHookedBuildInfo UnqualComponentName + | ConfigureScriptNotFound + | NoValidComponent + | ConfigureEitherSingleOrAll + | ConfigCIDValidForPreComponent + | SanitycheckForEnableComponents + | SanityCheckForDynamicStaticLinking + | UnsupportedLanguages PackageIdentifier CompilerId [String] + | UnsupportedLanguageExtension PackageIdentifier CompilerId [String] + | CantFindForeignLibraries [String] + | ExpectedAbsoluteDirectory FilePath + | FlagsNotSpecified [FlagName] + | EncounteredMissingDependency [Dependency] + | CompilerDoesntSupportThinning + | CompilerDoesntSupportReexports + | CompilerDoesntSupportBackpack + | LibraryWithinSamePackage [PackageId] + | ReportFailedDependencies [FailedDependency] String + | NoPackageDatabaseSpecified + | HowToFindInstalledPackages CompilerFlavor + | PkgConfigNotFound String String + | BadVersion String String PkgconfigVersion + | UnknownCompilerException + | NoWorkingGcc + | NoOSSupport OS + | NoCompilerSupport String + | InstallDirsNotPrefixRelative (InstallDirs FilePath) + | ExplainErrors (Maybe (Either [Char] [Char])) [String] + | CheckPackageProblems [String] + | LibDirDepsPrefixNotRelative FilePath FilePath + | CombinedConstraints Doc deriving (Show, Typeable) exceptionCode :: CabalException -> Int @@ -164,6 +213,42 @@ exceptionCode e = case e of NoSupportPreProcessingTestExtras{} -> 7886 NoSupportPreProcessingBenchmarkExtras{} -> 9999 UnlitException{} -> 5454 + RunProgramInvocationException{} -> 8012 + GetProgamInvocationException{} -> 7300 + GetProgramInvocationLBSException{} -> 6578 + CheckSemaphoreSupport{} -> 2002 + NoLibraryForPackage{} -> 8004 + SanityCheckHookedBuildInfo{} -> 6007 + ConfigureScriptNotFound{} -> 4567 + NoValidComponent{} -> 5680 + ConfigureEitherSingleOrAll{} -> 2001 + ConfigCIDValidForPreComponent{} -> 7006 + SanitycheckForEnableComponents{} -> 5004 + SanityCheckForDynamicStaticLinking{} -> 4007 + UnsupportedLanguages{} -> 8074 + UnsupportedLanguageExtension{} -> 5656 + CantFindForeignLibraries{} -> 4574 + ExpectedAbsoluteDirectory{} -> 6662 + FlagsNotSpecified{} -> 9080 + EncounteredMissingDependency{} -> 8010 + CompilerDoesntSupportThinning{} -> 4003 + CompilerDoesntSupportReexports{} -> 3456 + CompilerDoesntSupportBackpack{} -> 5446 + LibraryWithinSamePackage{} -> 7007 + ReportFailedDependencies{} -> 4321 + NoPackageDatabaseSpecified{} -> 2002 + HowToFindInstalledPackages{} -> 3003 + PkgConfigNotFound{} -> 7123 + BadVersion{} -> 7600 + UnknownCompilerException{} -> 3022 + NoWorkingGcc{} -> 1088 + NoOSSupport{} -> 3339 + NoCompilerSupport{} -> 2290 + InstallDirsNotPrefixRelative{} -> 6000 + ExplainErrors{} -> 4345 + CheckPackageProblems{} -> 5559 + LibDirDepsPrefixNotRelative{} -> 6667 + CombinedConstraints{} -> 5000 exceptionMessage :: CabalException -> String exceptionMessage e = case e of @@ -189,7 +274,7 @@ exceptionMessage e = case e of SuppressingChecksOnFile -> "HcPkg.register: the compiler does not support ,suppressing checks on files." NoSupportDirStylePackageDb -> "HcPkg.writeRegistrationFileDirectly: compiler does not support dir style package dbs" OnlySupportSpecificPackageDb -> "HcPkg.writeRegistrationFileDirectly: only supports SpecificPackageDB for now" - FailedToParseOutputDescribe programId packageId -> "failed to parse output of '" ++ programId ++ " describe " ++ prettyShow packageId ++ "'" + FailedToParseOutputDescribe programId pkgId -> "failed to parse output of '" ++ programId ++ " describe " ++ prettyShow pkgId ++ "'" DumpFailed programId exception -> programId ++ " dump failed: " ++ exception FailedToParseOutputDump programId -> "failed to parse output of '" ++ programId ++ " dump'" ListFailed programId -> programId ++ " list failed" @@ -353,3 +438,210 @@ exceptionMessage e = case e of ++ "type " ++ prettyShow tt UnlitException str -> str + RunProgramInvocationException path errors -> "'" ++ path ++ "' exited with an error:\n" ++ errors + GetProgamInvocationException path errors -> "'" ++ path ++ "' exited with an error:\n" ++ errors + GetProgramInvocationLBSException path errors -> "'" ++ path ++ "' exited with an error:\n" ++ errors + CheckSemaphoreSupport -> + "Your compiler does not support the -jsem flag. " + ++ "To use this feature you must use GHC 9.8 or later." + NoLibraryForPackage -> + "The buildinfo contains info for a library, " + ++ "but the package does not have a library." + SanityCheckHookedBuildInfo exe1 -> + "The buildinfo contains info for an executable called '" + ++ prettyShow exe1 + ++ "' but the package does not have a " + ++ "executable with that name." + ConfigureScriptNotFound -> "configure script not found." + NoValidComponent -> "No valid component targets found" + ConfigureEitherSingleOrAll -> "Can only configure either single component or all of them" + ConfigCIDValidForPreComponent -> "--cid is only supported for per-component configure" + SanitycheckForEnableComponents -> + "--enable-tests/--enable-benchmarks are incompatible with" + ++ " explicitly specifying a component to configure." + SanityCheckForDynamicStaticLinking -> + "--enable-executable-dynamic and --enable-executable-static" + ++ " are incompatible with each other." + UnsupportedLanguages pkgId compilerId langs -> + "The package " + ++ prettyShow (pkgId) + ++ " requires the following languages which are not " + ++ "supported by " + ++ prettyShow (compilerId) + ++ ": " + ++ intercalate ", " langs + UnsupportedLanguageExtension pkgId compilerId exts -> + "The package " + ++ prettyShow (pkgId) + ++ " requires the following language extensions which are not " + ++ "supported by " + ++ prettyShow (compilerId) + ++ ": " + ++ intercalate ", " exts + CantFindForeignLibraries unsupportedFLibs -> + "Cannot build some foreign libraries: " + ++ intercalate "," unsupportedFLibs + ExpectedAbsoluteDirectory fPath -> "expected an absolute directory name for --prefix: " ++ fPath + FlagsNotSpecified diffFlags -> + "'--exact-configuration' was given, " + ++ "but the following flags were not specified: " + ++ intercalate ", " (map show diffFlags) + EncounteredMissingDependency missing -> + "Encountered missing or private dependencies:\n" + ++ ( render + . nest 4 + . sep + . punctuate comma + . map (pretty . simplifyDependency) + $ missing + ) + CompilerDoesntSupportThinning -> + "Your compiler does not support thinning and renaming on " + ++ "package flags. To use this feature you must use " + ++ "GHC 7.9 or later." + CompilerDoesntSupportReexports -> + "Your compiler does not support module re-exports. To use " + ++ "this feature you must use GHC 7.9 or later." + CompilerDoesntSupportBackpack -> + "Your compiler does not support Backpack. To use " + ++ "this feature you must use GHC 8.1 or later." + LibraryWithinSamePackage internalPkgDeps -> + "The field 'build-depends: " + ++ intercalate ", " (map (prettyShow . packageName) internalPkgDeps) + ++ "' refers to a library which is defined within the same " + ++ "package. To use this feature the package must specify at " + ++ "least 'cabal-version: >= 1.8'." + ReportFailedDependencies failed hackageUrl -> (intercalate "\n\n" (map reportFailedDependency failed)) + where + reportFailedDependency (DependencyNotExists pkgname) = + "there is no version of " + ++ prettyShow pkgname + ++ " installed.\n" + ++ "Perhaps you need to download and install it from\n" + ++ hackageUrl + ++ prettyShow pkgname + ++ "?" + reportFailedDependency (DependencyMissingInternal pkgname lib) = + "internal dependency " + ++ prettyShow (prettyLibraryNameComponent lib) + ++ " not installed.\n" + ++ "Perhaps you need to configure and install it first?\n" + ++ "(This library was defined by " + ++ prettyShow pkgname + ++ ")" + reportFailedDependency (DependencyNoVersion dep) = + "cannot satisfy dependency " ++ prettyShow (simplifyDependency dep) ++ "\n" + NoPackageDatabaseSpecified -> + "No package databases have been specified. If you use " + ++ "--package-db=clear, you must follow it with --package-db= " + ++ "with 'global', 'user' or a specific file." + HowToFindInstalledPackages flv -> + "don't know how to find the installed packages for " + ++ prettyShow flv + PkgConfigNotFound pkg versionRequirement -> + "The pkg-config package '" + ++ pkg + ++ "'" + ++ versionRequirement + ++ " is required but it could not be found." + BadVersion pkg versionRequirement v -> + "The pkg-config package '" + ++ pkg + ++ "'" + ++ versionRequirement + ++ " is required but the version installed on the" + ++ " system is version " + ++ prettyShow v + UnknownCompilerException -> "Unknown compiler" + NoWorkingGcc -> + unlines + [ "No working gcc" + , "This package depends on foreign library but we cannot " + ++ "find a working C compiler. If you have it in a " + ++ "non-standard location you can use the --with-gcc " + ++ "flag to specify it." + ] + NoOSSupport os -> + "Operating system: " + ++ prettyShow os + ++ ", does not support relocatable builds" + NoCompilerSupport comp -> + "Compiler: " + ++ comp + ++ ", does not support relocatable builds" + InstallDirsNotPrefixRelative installDirs -> "Installation directories are not prefix_relative:\n" ++ show installDirs + ExplainErrors hdr libs -> + unlines $ + [ if plural + then "Missing dependencies on foreign libraries:" + else "Missing dependency on a foreign library:" + | missing + ] + ++ case hdr of + Just (Left h) -> ["* Missing (or bad) header file: " ++ h] + _ -> [] + ++ case libs of + [] -> [] + [lib] -> ["* Missing (or bad) C library: " ++ lib] + _ -> + [ "* Missing (or bad) C libraries: " + ++ intercalate ", " libs + ] + ++ [if plural then messagePlural else messageSingular | missing] + ++ case hdr of + Just (Left _) -> [headerCppMessage] + Just (Right h) -> + [ (if missing then "* " else "") + ++ "Bad header file: " + ++ h + , headerCcMessage + ] + _ -> [] + where + plural = length libs >= 2 + -- Is there something missing? (as opposed to broken) + missing = + not (null libs) + || case hdr of Just (Left _) -> True; _ -> False + messageSingular = + "This problem can usually be solved by installing the system " + ++ "package that provides this library (you may need the " + ++ "\"-dev\" version). If the library is already installed " + ++ "but in a non-standard location then you can use the flags " + ++ "--extra-include-dirs= and --extra-lib-dirs= to specify " + ++ "where it is." + ++ "If the library file does exist, it may contain errors that " + ++ "are caught by the C compiler at the preprocessing stage. " + ++ "In this case you can re-run configure with the verbosity " + ++ "flag -v3 to see the error messages." + messagePlural = + "This problem can usually be solved by installing the system " + ++ "packages that provide these libraries (you may need the " + ++ "\"-dev\" versions). If the libraries are already installed " + ++ "but in a non-standard location then you can use the flags " + ++ "--extra-include-dirs= and --extra-lib-dirs= to specify " + ++ "where they are." + ++ "If the library files do exist, it may contain errors that " + ++ "are caught by the C compiler at the preprocessing stage. " + ++ "In this case you can re-run configure with the verbosity " + ++ "flag -v3 to see the error messages." + headerCppMessage = + "If the header file does exist, it may contain errors that " + ++ "are caught by the C compiler at the preprocessing stage. " + ++ "In this case you can re-run configure with the verbosity " + ++ "flag -v3 to see the error messages." + headerCcMessage = + "The header file contains a compile error. " + ++ "You can re-run configure with the verbosity flag " + ++ "-v3 to see the error messages from the C compiler." + CheckPackageProblems errors -> (intercalate "\n\n" $ errors) + LibDirDepsPrefixNotRelative l p -> + "Library directory of a dependency: " + ++ show l + ++ "\nis not relative to the installation prefix:\n" + ++ show p + CombinedConstraints dispDepend -> + render $ + text "The following package dependencies were requested" + $+$ nest 4 dispDepend + $+$ text "however the given installed package instance does not exist." diff --git a/Cabal/src/Distribution/Simple/Program/Run.hs b/Cabal/src/Distribution/Simple/Program/Run.hs index bfc62896d91..5f7469914c4 100644 --- a/Cabal/src/Distribution/Simple/Program/Run.hs +++ b/Cabal/src/Distribution/Simple/Program/Run.hs @@ -31,11 +31,11 @@ import Distribution.Compat.Prelude import Prelude () import Distribution.Compat.Environment +import Distribution.Simple.Errors import Distribution.Simple.Program.Types import Distribution.Simple.Utils import Distribution.Utils.Generic import Distribution.Verbosity - import System.FilePath (searchPathSeparator) import qualified Data.ByteString.Lazy as LBS @@ -157,8 +157,8 @@ runProgramInvocation (Just input) IODataModeBinary when (exitCode /= ExitSuccess) $ - die' verbosity $ - "'" ++ path ++ "' exited with an error:\n" ++ errors + dieWithException verbosity $ + RunProgramInvocationException path errors where input = encodeToIOData encoding inputStr @@ -166,16 +166,16 @@ getProgramInvocationOutput :: Verbosity -> ProgramInvocation -> IO String getProgramInvocationOutput verbosity inv = do (output, errors, exitCode) <- getProgramInvocationOutputAndErrors verbosity inv when (exitCode /= ExitSuccess) $ - die' verbosity $ - "'" ++ progInvokePath inv ++ "' exited with an error:\n" ++ errors + dieWithException verbosity $ + GetProgamInvocationException (progInvokePath inv) errors return output getProgramInvocationLBS :: Verbosity -> ProgramInvocation -> IO LBS.ByteString getProgramInvocationLBS verbosity inv = do (output, errors, exitCode) <- getProgramInvocationIODataAndErrors verbosity inv IODataModeBinary when (exitCode /= ExitSuccess) $ - die' verbosity $ - "'" ++ progInvokePath inv ++ "' exited with an error:\n" ++ errors + dieWithException verbosity $ + GetProgramInvocationLBSException (progInvokePath inv) errors return output getProgramInvocationOutputAndErrors From d652de79b89539a30d9f5e3e3fbc1e01721dd802 Mon Sep 17 00:00:00 2001 From: SuganyaAK Date: Sun, 6 Aug 2023 20:50:30 -0400 Subject: [PATCH 02/16] Accepting new format of output with error codes --- Cabal/src/Distribution/Simple/Program/Run.hs | 2 +- .../PackageTests/AutogenModules/Package/setup.cabal.out | 3 ++- cabal-testsuite/PackageTests/AutogenModules/Package/setup.out | 3 ++- .../PackageTests/Backpack/Reexport2/setup.cabal.out | 3 ++- cabal-testsuite/PackageTests/Backpack/Reexport2/setup.out | 3 ++- .../PackageTests/BuildDeps/InternalLibrary0/setup.cabal.out | 3 ++- .../PackageTests/BuildDeps/InternalLibrary0/setup.out | 3 ++- .../BuildToolDependsInternalMissing/setup.cabal.out | 3 ++- .../PackageTests/BuildToolDependsInternalMissing/setup.out | 3 ++- .../ConfigureComponent/SubLib/setup-explicit-fail.out | 3 ++- .../InternalVersions/BuildDependsBad/setup.cabal.out | 3 ++- .../PackageTests/InternalVersions/BuildDependsBad/setup.out | 3 ++- .../InternalVersions/BuildToolDependsBad/setup.cabal.out | 3 ++- .../InternalVersions/BuildToolDependsBad/setup.out | 3 ++- .../InternalVersions/BuildToolsBad/setup.cabal.out | 3 ++- .../PackageTests/InternalVersions/BuildToolsBad/setup.out | 3 ++- 16 files changed, 31 insertions(+), 16 deletions(-) diff --git a/Cabal/src/Distribution/Simple/Program/Run.hs b/Cabal/src/Distribution/Simple/Program/Run.hs index 5f7469914c4..927af778a88 100644 --- a/Cabal/src/Distribution/Simple/Program/Run.hs +++ b/Cabal/src/Distribution/Simple/Program/Run.hs @@ -167,7 +167,7 @@ getProgramInvocationOutput verbosity inv = do (output, errors, exitCode) <- getProgramInvocationOutputAndErrors verbosity inv when (exitCode /= ExitSuccess) $ dieWithException verbosity $ - GetProgamInvocationException (progInvokePath inv) errors + GetProgamInvocationException (progInvokePath inv) errors return output getProgramInvocationLBS :: Verbosity -> ProgramInvocation -> IO LBS.ByteString diff --git a/cabal-testsuite/PackageTests/AutogenModules/Package/setup.cabal.out b/cabal-testsuite/PackageTests/AutogenModules/Package/setup.cabal.out index 0e0ba47ae67..d75804e0c8f 100644 --- a/cabal-testsuite/PackageTests/AutogenModules/Package/setup.cabal.out +++ b/cabal-testsuite/PackageTests/AutogenModules/Package/setup.cabal.out @@ -1,6 +1,7 @@ # Setup configure Configuring AutogenModules-0.1... -Error: cabal: An 'autogen-module' is neither on 'exposed-modules' or 'other-modules'. +Error: [Cabal-5559] +An 'autogen-module' is neither on 'exposed-modules' or 'other-modules'. On executable 'Exe' an 'autogen-module' is not on 'other-modules' diff --git a/cabal-testsuite/PackageTests/AutogenModules/Package/setup.out b/cabal-testsuite/PackageTests/AutogenModules/Package/setup.out index b19916e9329..d75804e0c8f 100644 --- a/cabal-testsuite/PackageTests/AutogenModules/Package/setup.out +++ b/cabal-testsuite/PackageTests/AutogenModules/Package/setup.out @@ -1,6 +1,7 @@ # Setup configure Configuring AutogenModules-0.1... -Error: setup: An 'autogen-module' is neither on 'exposed-modules' or 'other-modules'. +Error: [Cabal-5559] +An 'autogen-module' is neither on 'exposed-modules' or 'other-modules'. On executable 'Exe' an 'autogen-module' is not on 'other-modules' diff --git a/cabal-testsuite/PackageTests/Backpack/Reexport2/setup.cabal.out b/cabal-testsuite/PackageTests/Backpack/Reexport2/setup.cabal.out index 2f94ecbb228..75bc0f494a7 100644 --- a/cabal-testsuite/PackageTests/Backpack/Reexport2/setup.cabal.out +++ b/cabal-testsuite/PackageTests/Backpack/Reexport2/setup.cabal.out @@ -1,3 +1,4 @@ # Setup configure Configuring Reexport2-1.0... -Error: cabal: Duplicate modules in library: Asdf +Error: [Cabal-5559] +Duplicate modules in library: Asdf diff --git a/cabal-testsuite/PackageTests/Backpack/Reexport2/setup.out b/cabal-testsuite/PackageTests/Backpack/Reexport2/setup.out index 58f2330e0d3..75bc0f494a7 100644 --- a/cabal-testsuite/PackageTests/Backpack/Reexport2/setup.out +++ b/cabal-testsuite/PackageTests/Backpack/Reexport2/setup.out @@ -1,3 +1,4 @@ # Setup configure Configuring Reexport2-1.0... -Error: setup: Duplicate modules in library: Asdf +Error: [Cabal-5559] +Duplicate modules in library: Asdf diff --git a/cabal-testsuite/PackageTests/BuildDeps/InternalLibrary0/setup.cabal.out b/cabal-testsuite/PackageTests/BuildDeps/InternalLibrary0/setup.cabal.out index 14aba5dcbbb..391531a89e2 100644 --- a/cabal-testsuite/PackageTests/BuildDeps/InternalLibrary0/setup.cabal.out +++ b/cabal-testsuite/PackageTests/BuildDeps/InternalLibrary0/setup.cabal.out @@ -1,3 +1,4 @@ # Setup configure Configuring InternalLibrary0-0.1... -Error: cabal: The field 'build-depends: InternalLibrary0' refers to a library which is defined within the same package. To use this feature the package must specify at least 'cabal-version: >= 1.8'. +Error: [Cabal-7007] +The field 'build-depends: InternalLibrary0' refers to a library which is defined within the same package. To use this feature the package must specify at least 'cabal-version: >= 1.8'. diff --git a/cabal-testsuite/PackageTests/BuildDeps/InternalLibrary0/setup.out b/cabal-testsuite/PackageTests/BuildDeps/InternalLibrary0/setup.out index 0a464192dc9..391531a89e2 100644 --- a/cabal-testsuite/PackageTests/BuildDeps/InternalLibrary0/setup.out +++ b/cabal-testsuite/PackageTests/BuildDeps/InternalLibrary0/setup.out @@ -1,3 +1,4 @@ # Setup configure Configuring InternalLibrary0-0.1... -Error: setup: The field 'build-depends: InternalLibrary0' refers to a library which is defined within the same package. To use this feature the package must specify at least 'cabal-version: >= 1.8'. +Error: [Cabal-7007] +The field 'build-depends: InternalLibrary0' refers to a library which is defined within the same package. To use this feature the package must specify at least 'cabal-version: >= 1.8'. diff --git a/cabal-testsuite/PackageTests/BuildToolDependsInternalMissing/setup.cabal.out b/cabal-testsuite/PackageTests/BuildToolDependsInternalMissing/setup.cabal.out index fce5331e560..da5c074772e 100644 --- a/cabal-testsuite/PackageTests/BuildToolDependsInternalMissing/setup.cabal.out +++ b/cabal-testsuite/PackageTests/BuildToolDependsInternalMissing/setup.cabal.out @@ -1,3 +1,4 @@ # Setup configure Configuring build-tool-depends-missing-0.1.0.0... -Error: cabal: The package depends on a missing internal executable: build-tool-depends-missing:hello-world +Error: [Cabal-5559] +The package depends on a missing internal executable: build-tool-depends-missing:hello-world diff --git a/cabal-testsuite/PackageTests/BuildToolDependsInternalMissing/setup.out b/cabal-testsuite/PackageTests/BuildToolDependsInternalMissing/setup.out index 861f95ddeb8..da5c074772e 100644 --- a/cabal-testsuite/PackageTests/BuildToolDependsInternalMissing/setup.out +++ b/cabal-testsuite/PackageTests/BuildToolDependsInternalMissing/setup.out @@ -1,3 +1,4 @@ # Setup configure Configuring build-tool-depends-missing-0.1.0.0... -Error: setup: The package depends on a missing internal executable: build-tool-depends-missing:hello-world +Error: [Cabal-5559] +The package depends on a missing internal executable: build-tool-depends-missing:hello-world diff --git a/cabal-testsuite/PackageTests/ConfigureComponent/SubLib/setup-explicit-fail.out b/cabal-testsuite/PackageTests/ConfigureComponent/SubLib/setup-explicit-fail.out index 3726ef6fb23..fec347864e5 100644 --- a/cabal-testsuite/PackageTests/ConfigureComponent/SubLib/setup-explicit-fail.out +++ b/cabal-testsuite/PackageTests/ConfigureComponent/SubLib/setup-explicit-fail.out @@ -9,5 +9,6 @@ Installing internal library sublib in Registering library 'sublib' for Lib-0.1.0.0... # Setup configure Configuring executable 'exe' for Lib-0.1.0.0... -Error: setup: Encountered missing or private dependencies: +Error: [Cabal-8010] +Encountered missing or private dependencies: Lib:sublib diff --git a/cabal-testsuite/PackageTests/InternalVersions/BuildDependsBad/setup.cabal.out b/cabal-testsuite/PackageTests/InternalVersions/BuildDependsBad/setup.cabal.out index 843f2e7808a..b03e6765cb0 100644 --- a/cabal-testsuite/PackageTests/InternalVersions/BuildDependsBad/setup.cabal.out +++ b/cabal-testsuite/PackageTests/InternalVersions/BuildDependsBad/setup.cabal.out @@ -1,3 +1,4 @@ # Setup configure Configuring build-depends-bad-version-0.1.0.0... -Error: cabal: The package has an impossible version range for a dependency on an internal library: build-depends-bad-version >=2. This version range does not include the current package, and must be removed as the current package's library will always be used. +Error: [Cabal-5559] +The package has an impossible version range for a dependency on an internal library: build-depends-bad-version >=2. This version range does not include the current package, and must be removed as the current package's library will always be used. diff --git a/cabal-testsuite/PackageTests/InternalVersions/BuildDependsBad/setup.out b/cabal-testsuite/PackageTests/InternalVersions/BuildDependsBad/setup.out index e0b6883000a..b03e6765cb0 100644 --- a/cabal-testsuite/PackageTests/InternalVersions/BuildDependsBad/setup.out +++ b/cabal-testsuite/PackageTests/InternalVersions/BuildDependsBad/setup.out @@ -1,3 +1,4 @@ # Setup configure Configuring build-depends-bad-version-0.1.0.0... -Error: setup: The package has an impossible version range for a dependency on an internal library: build-depends-bad-version >=2. This version range does not include the current package, and must be removed as the current package's library will always be used. +Error: [Cabal-5559] +The package has an impossible version range for a dependency on an internal library: build-depends-bad-version >=2. This version range does not include the current package, and must be removed as the current package's library will always be used. diff --git a/cabal-testsuite/PackageTests/InternalVersions/BuildToolDependsBad/setup.cabal.out b/cabal-testsuite/PackageTests/InternalVersions/BuildToolDependsBad/setup.cabal.out index d92e9e784e5..077f750b066 100644 --- a/cabal-testsuite/PackageTests/InternalVersions/BuildToolDependsBad/setup.cabal.out +++ b/cabal-testsuite/PackageTests/InternalVersions/BuildToolDependsBad/setup.cabal.out @@ -1,3 +1,4 @@ # Setup configure Configuring build-tool-depends-bad-version-0.1.0.0... -Error: cabal: The package has an impossible version range for a dependency on an internal executable: build-tool-depends-bad-version:hello-world >=2. This version range does not include the current package, and must be removed as the current package's executable will always be used. +Error: [Cabal-5559] +The package has an impossible version range for a dependency on an internal executable: build-tool-depends-bad-version:hello-world >=2. This version range does not include the current package, and must be removed as the current package's executable will always be used. diff --git a/cabal-testsuite/PackageTests/InternalVersions/BuildToolDependsBad/setup.out b/cabal-testsuite/PackageTests/InternalVersions/BuildToolDependsBad/setup.out index eeb1226a74f..077f750b066 100644 --- a/cabal-testsuite/PackageTests/InternalVersions/BuildToolDependsBad/setup.out +++ b/cabal-testsuite/PackageTests/InternalVersions/BuildToolDependsBad/setup.out @@ -1,3 +1,4 @@ # Setup configure Configuring build-tool-depends-bad-version-0.1.0.0... -Error: setup: The package has an impossible version range for a dependency on an internal executable: build-tool-depends-bad-version:hello-world >=2. This version range does not include the current package, and must be removed as the current package's executable will always be used. +Error: [Cabal-5559] +The package has an impossible version range for a dependency on an internal executable: build-tool-depends-bad-version:hello-world >=2. This version range does not include the current package, and must be removed as the current package's executable will always be used. diff --git a/cabal-testsuite/PackageTests/InternalVersions/BuildToolsBad/setup.cabal.out b/cabal-testsuite/PackageTests/InternalVersions/BuildToolsBad/setup.cabal.out index 44f43d8b30b..68a45e22992 100644 --- a/cabal-testsuite/PackageTests/InternalVersions/BuildToolsBad/setup.cabal.out +++ b/cabal-testsuite/PackageTests/InternalVersions/BuildToolsBad/setup.cabal.out @@ -1,3 +1,4 @@ # Setup configure Configuring build-tools-bad-version-0.1.0.0... -Error: cabal: The package has an impossible version range for a dependency on an internal executable: build-tools-bad-version:hello-world >=2. This version range does not include the current package, and must be removed as the current package's executable will always be used. +Error: [Cabal-5559] +The package has an impossible version range for a dependency on an internal executable: build-tools-bad-version:hello-world >=2. This version range does not include the current package, and must be removed as the current package's executable will always be used. diff --git a/cabal-testsuite/PackageTests/InternalVersions/BuildToolsBad/setup.out b/cabal-testsuite/PackageTests/InternalVersions/BuildToolsBad/setup.out index 06aaa652bce..68a45e22992 100644 --- a/cabal-testsuite/PackageTests/InternalVersions/BuildToolsBad/setup.out +++ b/cabal-testsuite/PackageTests/InternalVersions/BuildToolsBad/setup.out @@ -1,3 +1,4 @@ # Setup configure Configuring build-tools-bad-version-0.1.0.0... -Error: setup: The package has an impossible version range for a dependency on an internal executable: build-tools-bad-version:hello-world >=2. This version range does not include the current package, and must be removed as the current package's executable will always be used. +Error: [Cabal-5559] +The package has an impossible version range for a dependency on an internal executable: build-tools-bad-version:hello-world >=2. This version range does not include the current package, and must be removed as the current package's executable will always be used. From 14ba477b54a67b722e1a30fd15065f0b68e09c59 Mon Sep 17 00:00:00 2001 From: SuganyaAK Date: Sun, 6 Aug 2023 23:11:12 -0400 Subject: [PATCH 03/16] Reverting the changes to new error output --- .../PackageTests/AutogenModules/Package/setup.cabal.out | 3 +-- .../PackageTests/AutogenModules/Package/setup.out | 3 +-- .../PackageTests/Backpack/Reexport2/setup.cabal.out | 3 +-- cabal-testsuite/PackageTests/Backpack/Reexport2/setup.out | 3 +-- .../PackageTests/BuildDeps/InternalLibrary0/setup.cabal.out | 3 +-- .../PackageTests/BuildDeps/InternalLibrary0/setup.out | 3 +-- .../BuildToolDependsInternalMissing/setup.cabal.out | 3 +-- .../PackageTests/BuildToolDependsInternalMissing/setup.out | 3 +-- .../ConfigureComponent/SubLib/setup-explicit-fail.out | 5 ++--- .../InternalVersions/BuildDependsBad/setup.cabal.out | 3 +-- .../PackageTests/InternalVersions/BuildDependsBad/setup.out | 3 +-- .../InternalVersions/BuildToolDependsBad/setup.cabal.out | 3 +-- .../InternalVersions/BuildToolDependsBad/setup.out | 3 +-- .../InternalVersions/BuildToolsBad/setup.cabal.out | 3 +-- .../PackageTests/InternalVersions/BuildToolsBad/setup.out | 3 +-- 15 files changed, 16 insertions(+), 31 deletions(-) diff --git a/cabal-testsuite/PackageTests/AutogenModules/Package/setup.cabal.out b/cabal-testsuite/PackageTests/AutogenModules/Package/setup.cabal.out index d75804e0c8f..0e0ba47ae67 100644 --- a/cabal-testsuite/PackageTests/AutogenModules/Package/setup.cabal.out +++ b/cabal-testsuite/PackageTests/AutogenModules/Package/setup.cabal.out @@ -1,7 +1,6 @@ # Setup configure Configuring AutogenModules-0.1... -Error: [Cabal-5559] -An 'autogen-module' is neither on 'exposed-modules' or 'other-modules'. +Error: cabal: An 'autogen-module' is neither on 'exposed-modules' or 'other-modules'. On executable 'Exe' an 'autogen-module' is not on 'other-modules' diff --git a/cabal-testsuite/PackageTests/AutogenModules/Package/setup.out b/cabal-testsuite/PackageTests/AutogenModules/Package/setup.out index d75804e0c8f..b19916e9329 100644 --- a/cabal-testsuite/PackageTests/AutogenModules/Package/setup.out +++ b/cabal-testsuite/PackageTests/AutogenModules/Package/setup.out @@ -1,7 +1,6 @@ # Setup configure Configuring AutogenModules-0.1... -Error: [Cabal-5559] -An 'autogen-module' is neither on 'exposed-modules' or 'other-modules'. +Error: setup: An 'autogen-module' is neither on 'exposed-modules' or 'other-modules'. On executable 'Exe' an 'autogen-module' is not on 'other-modules' diff --git a/cabal-testsuite/PackageTests/Backpack/Reexport2/setup.cabal.out b/cabal-testsuite/PackageTests/Backpack/Reexport2/setup.cabal.out index 75bc0f494a7..2f94ecbb228 100644 --- a/cabal-testsuite/PackageTests/Backpack/Reexport2/setup.cabal.out +++ b/cabal-testsuite/PackageTests/Backpack/Reexport2/setup.cabal.out @@ -1,4 +1,3 @@ # Setup configure Configuring Reexport2-1.0... -Error: [Cabal-5559] -Duplicate modules in library: Asdf +Error: cabal: Duplicate modules in library: Asdf diff --git a/cabal-testsuite/PackageTests/Backpack/Reexport2/setup.out b/cabal-testsuite/PackageTests/Backpack/Reexport2/setup.out index 75bc0f494a7..58f2330e0d3 100644 --- a/cabal-testsuite/PackageTests/Backpack/Reexport2/setup.out +++ b/cabal-testsuite/PackageTests/Backpack/Reexport2/setup.out @@ -1,4 +1,3 @@ # Setup configure Configuring Reexport2-1.0... -Error: [Cabal-5559] -Duplicate modules in library: Asdf +Error: setup: Duplicate modules in library: Asdf diff --git a/cabal-testsuite/PackageTests/BuildDeps/InternalLibrary0/setup.cabal.out b/cabal-testsuite/PackageTests/BuildDeps/InternalLibrary0/setup.cabal.out index 391531a89e2..14aba5dcbbb 100644 --- a/cabal-testsuite/PackageTests/BuildDeps/InternalLibrary0/setup.cabal.out +++ b/cabal-testsuite/PackageTests/BuildDeps/InternalLibrary0/setup.cabal.out @@ -1,4 +1,3 @@ # Setup configure Configuring InternalLibrary0-0.1... -Error: [Cabal-7007] -The field 'build-depends: InternalLibrary0' refers to a library which is defined within the same package. To use this feature the package must specify at least 'cabal-version: >= 1.8'. +Error: cabal: The field 'build-depends: InternalLibrary0' refers to a library which is defined within the same package. To use this feature the package must specify at least 'cabal-version: >= 1.8'. diff --git a/cabal-testsuite/PackageTests/BuildDeps/InternalLibrary0/setup.out b/cabal-testsuite/PackageTests/BuildDeps/InternalLibrary0/setup.out index 391531a89e2..0a464192dc9 100644 --- a/cabal-testsuite/PackageTests/BuildDeps/InternalLibrary0/setup.out +++ b/cabal-testsuite/PackageTests/BuildDeps/InternalLibrary0/setup.out @@ -1,4 +1,3 @@ # Setup configure Configuring InternalLibrary0-0.1... -Error: [Cabal-7007] -The field 'build-depends: InternalLibrary0' refers to a library which is defined within the same package. To use this feature the package must specify at least 'cabal-version: >= 1.8'. +Error: setup: The field 'build-depends: InternalLibrary0' refers to a library which is defined within the same package. To use this feature the package must specify at least 'cabal-version: >= 1.8'. diff --git a/cabal-testsuite/PackageTests/BuildToolDependsInternalMissing/setup.cabal.out b/cabal-testsuite/PackageTests/BuildToolDependsInternalMissing/setup.cabal.out index da5c074772e..059c3214d71 100644 --- a/cabal-testsuite/PackageTests/BuildToolDependsInternalMissing/setup.cabal.out +++ b/cabal-testsuite/PackageTests/BuildToolDependsInternalMissing/setup.cabal.out @@ -1,4 +1,3 @@ # Setup configure Configuring build-tool-depends-missing-0.1.0.0... -Error: [Cabal-5559] -The package depends on a missing internal executable: build-tool-depends-missing:hello-world +Error: cabal: The package depends on a missing internal executable: build-tool-depends-missing:hello-world \ No newline at end of file diff --git a/cabal-testsuite/PackageTests/BuildToolDependsInternalMissing/setup.out b/cabal-testsuite/PackageTests/BuildToolDependsInternalMissing/setup.out index da5c074772e..861f95ddeb8 100644 --- a/cabal-testsuite/PackageTests/BuildToolDependsInternalMissing/setup.out +++ b/cabal-testsuite/PackageTests/BuildToolDependsInternalMissing/setup.out @@ -1,4 +1,3 @@ # Setup configure Configuring build-tool-depends-missing-0.1.0.0... -Error: [Cabal-5559] -The package depends on a missing internal executable: build-tool-depends-missing:hello-world +Error: setup: The package depends on a missing internal executable: build-tool-depends-missing:hello-world diff --git a/cabal-testsuite/PackageTests/ConfigureComponent/SubLib/setup-explicit-fail.out b/cabal-testsuite/PackageTests/ConfigureComponent/SubLib/setup-explicit-fail.out index fec347864e5..4240b4aea38 100644 --- a/cabal-testsuite/PackageTests/ConfigureComponent/SubLib/setup-explicit-fail.out +++ b/cabal-testsuite/PackageTests/ConfigureComponent/SubLib/setup-explicit-fail.out @@ -9,6 +9,5 @@ Installing internal library sublib in Registering library 'sublib' for Lib-0.1.0.0... # Setup configure Configuring executable 'exe' for Lib-0.1.0.0... -Error: [Cabal-8010] -Encountered missing or private dependencies: - Lib:sublib +Error: setup: Encountered missing or private dependencies: + Lib:sublib \ No newline at end of file diff --git a/cabal-testsuite/PackageTests/InternalVersions/BuildDependsBad/setup.cabal.out b/cabal-testsuite/PackageTests/InternalVersions/BuildDependsBad/setup.cabal.out index b03e6765cb0..843f2e7808a 100644 --- a/cabal-testsuite/PackageTests/InternalVersions/BuildDependsBad/setup.cabal.out +++ b/cabal-testsuite/PackageTests/InternalVersions/BuildDependsBad/setup.cabal.out @@ -1,4 +1,3 @@ # Setup configure Configuring build-depends-bad-version-0.1.0.0... -Error: [Cabal-5559] -The package has an impossible version range for a dependency on an internal library: build-depends-bad-version >=2. This version range does not include the current package, and must be removed as the current package's library will always be used. +Error: cabal: The package has an impossible version range for a dependency on an internal library: build-depends-bad-version >=2. This version range does not include the current package, and must be removed as the current package's library will always be used. diff --git a/cabal-testsuite/PackageTests/InternalVersions/BuildDependsBad/setup.out b/cabal-testsuite/PackageTests/InternalVersions/BuildDependsBad/setup.out index b03e6765cb0..e0b6883000a 100644 --- a/cabal-testsuite/PackageTests/InternalVersions/BuildDependsBad/setup.out +++ b/cabal-testsuite/PackageTests/InternalVersions/BuildDependsBad/setup.out @@ -1,4 +1,3 @@ # Setup configure Configuring build-depends-bad-version-0.1.0.0... -Error: [Cabal-5559] -The package has an impossible version range for a dependency on an internal library: build-depends-bad-version >=2. This version range does not include the current package, and must be removed as the current package's library will always be used. +Error: setup: The package has an impossible version range for a dependency on an internal library: build-depends-bad-version >=2. This version range does not include the current package, and must be removed as the current package's library will always be used. diff --git a/cabal-testsuite/PackageTests/InternalVersions/BuildToolDependsBad/setup.cabal.out b/cabal-testsuite/PackageTests/InternalVersions/BuildToolDependsBad/setup.cabal.out index 077f750b066..d92e9e784e5 100644 --- a/cabal-testsuite/PackageTests/InternalVersions/BuildToolDependsBad/setup.cabal.out +++ b/cabal-testsuite/PackageTests/InternalVersions/BuildToolDependsBad/setup.cabal.out @@ -1,4 +1,3 @@ # Setup configure Configuring build-tool-depends-bad-version-0.1.0.0... -Error: [Cabal-5559] -The package has an impossible version range for a dependency on an internal executable: build-tool-depends-bad-version:hello-world >=2. This version range does not include the current package, and must be removed as the current package's executable will always be used. +Error: cabal: The package has an impossible version range for a dependency on an internal executable: build-tool-depends-bad-version:hello-world >=2. This version range does not include the current package, and must be removed as the current package's executable will always be used. diff --git a/cabal-testsuite/PackageTests/InternalVersions/BuildToolDependsBad/setup.out b/cabal-testsuite/PackageTests/InternalVersions/BuildToolDependsBad/setup.out index 077f750b066..eeb1226a74f 100644 --- a/cabal-testsuite/PackageTests/InternalVersions/BuildToolDependsBad/setup.out +++ b/cabal-testsuite/PackageTests/InternalVersions/BuildToolDependsBad/setup.out @@ -1,4 +1,3 @@ # Setup configure Configuring build-tool-depends-bad-version-0.1.0.0... -Error: [Cabal-5559] -The package has an impossible version range for a dependency on an internal executable: build-tool-depends-bad-version:hello-world >=2. This version range does not include the current package, and must be removed as the current package's executable will always be used. +Error: setup: The package has an impossible version range for a dependency on an internal executable: build-tool-depends-bad-version:hello-world >=2. This version range does not include the current package, and must be removed as the current package's executable will always be used. diff --git a/cabal-testsuite/PackageTests/InternalVersions/BuildToolsBad/setup.cabal.out b/cabal-testsuite/PackageTests/InternalVersions/BuildToolsBad/setup.cabal.out index 68a45e22992..44f43d8b30b 100644 --- a/cabal-testsuite/PackageTests/InternalVersions/BuildToolsBad/setup.cabal.out +++ b/cabal-testsuite/PackageTests/InternalVersions/BuildToolsBad/setup.cabal.out @@ -1,4 +1,3 @@ # Setup configure Configuring build-tools-bad-version-0.1.0.0... -Error: [Cabal-5559] -The package has an impossible version range for a dependency on an internal executable: build-tools-bad-version:hello-world >=2. This version range does not include the current package, and must be removed as the current package's executable will always be used. +Error: cabal: The package has an impossible version range for a dependency on an internal executable: build-tools-bad-version:hello-world >=2. This version range does not include the current package, and must be removed as the current package's executable will always be used. diff --git a/cabal-testsuite/PackageTests/InternalVersions/BuildToolsBad/setup.out b/cabal-testsuite/PackageTests/InternalVersions/BuildToolsBad/setup.out index 68a45e22992..06aaa652bce 100644 --- a/cabal-testsuite/PackageTests/InternalVersions/BuildToolsBad/setup.out +++ b/cabal-testsuite/PackageTests/InternalVersions/BuildToolsBad/setup.out @@ -1,4 +1,3 @@ # Setup configure Configuring build-tools-bad-version-0.1.0.0... -Error: [Cabal-5559] -The package has an impossible version range for a dependency on an internal executable: build-tools-bad-version:hello-world >=2. This version range does not include the current package, and must be removed as the current package's executable will always be used. +Error: setup: The package has an impossible version range for a dependency on an internal executable: build-tools-bad-version:hello-world >=2. This version range does not include the current package, and must be removed as the current package's executable will always be used. From f70082275fcfaa65f61deb96f1fb1d48518b156b Mon Sep 17 00:00:00 2001 From: SuganyaAK Date: Sun, 6 Aug 2023 23:49:42 -0400 Subject: [PATCH 04/16] Rebasing branch Subsequent Cabal Package errors --- .../SubLib/setup-explicit-fail.out | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 cabal-testsuite/PackageTests/ConfigureComponent/SubLib/setup-explicit-fail.out diff --git a/cabal-testsuite/PackageTests/ConfigureComponent/SubLib/setup-explicit-fail.out b/cabal-testsuite/PackageTests/ConfigureComponent/SubLib/setup-explicit-fail.out deleted file mode 100644 index 4240b4aea38..00000000000 --- a/cabal-testsuite/PackageTests/ConfigureComponent/SubLib/setup-explicit-fail.out +++ /dev/null @@ -1,13 +0,0 @@ -# Setup configure -Configuring library 'sublib' for Lib-0.1.0.0... -# Setup build -Preprocessing library 'sublib' for Lib-0.1.0.0... -Building library 'sublib' for Lib-0.1.0.0... -# Setup copy -Installing internal library sublib in -# Setup register -Registering library 'sublib' for Lib-0.1.0.0... -# Setup configure -Configuring executable 'exe' for Lib-0.1.0.0... -Error: setup: Encountered missing or private dependencies: - Lib:sublib \ No newline at end of file From 4d2d5933fd46d87d56336f74287e8bc1ed4da50e Mon Sep 17 00:00:00 2001 From: Suganya Raju <99989138+SuganyaAK@users.noreply.github.com> Date: Mon, 7 Aug 2023 17:04:53 -0400 Subject: [PATCH 05/16] Delete setup-explicit-fail.out --- .../SubLib/setup-explicit-fail.out | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 cabal-testsuite/PackageTests/ConfigureComponent/SubLib/setup-explicit-fail.out diff --git a/cabal-testsuite/PackageTests/ConfigureComponent/SubLib/setup-explicit-fail.out b/cabal-testsuite/PackageTests/ConfigureComponent/SubLib/setup-explicit-fail.out deleted file mode 100644 index fec347864e5..00000000000 --- a/cabal-testsuite/PackageTests/ConfigureComponent/SubLib/setup-explicit-fail.out +++ /dev/null @@ -1,14 +0,0 @@ -# Setup configure -Configuring library 'sublib' for Lib-0.1.0.0... -# Setup build -Preprocessing library 'sublib' for Lib-0.1.0.0... -Building library 'sublib' for Lib-0.1.0.0... -# Setup copy -Installing internal library sublib in -# Setup register -Registering library 'sublib' for Lib-0.1.0.0... -# Setup configure -Configuring executable 'exe' for Lib-0.1.0.0... -Error: [Cabal-8010] -Encountered missing or private dependencies: - Lib:sublib From 115b874ac06731905f80ec44906ea2280895b8d6 Mon Sep 17 00:00:00 2001 From: SuganyaAK Date: Mon, 7 Aug 2023 02:18:46 -0400 Subject: [PATCH 06/16] Added setup-explicit-fail.out --- .../SubLib/setup-explicit-fail.out | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 cabal-testsuite/PackageTests/ConfigureComponent/SubLib/setup-explicit-fail.out diff --git a/cabal-testsuite/PackageTests/ConfigureComponent/SubLib/setup-explicit-fail.out b/cabal-testsuite/PackageTests/ConfigureComponent/SubLib/setup-explicit-fail.out new file mode 100644 index 00000000000..3726ef6fb23 --- /dev/null +++ b/cabal-testsuite/PackageTests/ConfigureComponent/SubLib/setup-explicit-fail.out @@ -0,0 +1,13 @@ +# Setup configure +Configuring library 'sublib' for Lib-0.1.0.0... +# Setup build +Preprocessing library 'sublib' for Lib-0.1.0.0... +Building library 'sublib' for Lib-0.1.0.0... +# Setup copy +Installing internal library sublib in +# Setup register +Registering library 'sublib' for Lib-0.1.0.0... +# Setup configure +Configuring executable 'exe' for Lib-0.1.0.0... +Error: setup: Encountered missing or private dependencies: + Lib:sublib From cf4787138dc060ce6ff12a85d6836628bb8015cb Mon Sep 17 00:00:00 2001 From: SuganyaAK Date: Tue, 8 Aug 2023 13:51:53 -0400 Subject: [PATCH 07/16] Accepting new output with error codes --- .../PackageTests/AutogenModules/Package/setup.cabal.out | 3 ++- cabal-testsuite/PackageTests/AutogenModules/Package/setup.out | 3 ++- .../PackageTests/Backpack/Reexport2/setup.cabal.out | 3 ++- cabal-testsuite/PackageTests/Backpack/Reexport2/setup.out | 3 ++- .../PackageTests/BuildDeps/InternalLibrary0/setup.cabal.out | 3 ++- .../PackageTests/BuildDeps/InternalLibrary0/setup.out | 3 ++- .../BuildToolDependsInternalMissing/setup.cabal.out | 3 ++- .../PackageTests/BuildToolDependsInternalMissing/setup.out | 3 ++- .../ConfigureComponent/SubLib/setup-explicit-fail.out | 3 ++- .../InternalVersions/BuildDependsBad/setup.cabal.out | 3 ++- .../PackageTests/InternalVersions/BuildDependsBad/setup.out | 3 ++- .../InternalVersions/BuildToolDependsBad/setup.cabal.out | 3 ++- .../InternalVersions/BuildToolDependsBad/setup.out | 3 ++- .../InternalVersions/BuildToolsBad/setup.cabal.out | 3 ++- .../PackageTests/InternalVersions/BuildToolsBad/setup.out | 3 ++- 15 files changed, 30 insertions(+), 15 deletions(-) diff --git a/cabal-testsuite/PackageTests/AutogenModules/Package/setup.cabal.out b/cabal-testsuite/PackageTests/AutogenModules/Package/setup.cabal.out index 0e0ba47ae67..d75804e0c8f 100644 --- a/cabal-testsuite/PackageTests/AutogenModules/Package/setup.cabal.out +++ b/cabal-testsuite/PackageTests/AutogenModules/Package/setup.cabal.out @@ -1,6 +1,7 @@ # Setup configure Configuring AutogenModules-0.1... -Error: cabal: An 'autogen-module' is neither on 'exposed-modules' or 'other-modules'. +Error: [Cabal-5559] +An 'autogen-module' is neither on 'exposed-modules' or 'other-modules'. On executable 'Exe' an 'autogen-module' is not on 'other-modules' diff --git a/cabal-testsuite/PackageTests/AutogenModules/Package/setup.out b/cabal-testsuite/PackageTests/AutogenModules/Package/setup.out index b19916e9329..d75804e0c8f 100644 --- a/cabal-testsuite/PackageTests/AutogenModules/Package/setup.out +++ b/cabal-testsuite/PackageTests/AutogenModules/Package/setup.out @@ -1,6 +1,7 @@ # Setup configure Configuring AutogenModules-0.1... -Error: setup: An 'autogen-module' is neither on 'exposed-modules' or 'other-modules'. +Error: [Cabal-5559] +An 'autogen-module' is neither on 'exposed-modules' or 'other-modules'. On executable 'Exe' an 'autogen-module' is not on 'other-modules' diff --git a/cabal-testsuite/PackageTests/Backpack/Reexport2/setup.cabal.out b/cabal-testsuite/PackageTests/Backpack/Reexport2/setup.cabal.out index 2f94ecbb228..75bc0f494a7 100644 --- a/cabal-testsuite/PackageTests/Backpack/Reexport2/setup.cabal.out +++ b/cabal-testsuite/PackageTests/Backpack/Reexport2/setup.cabal.out @@ -1,3 +1,4 @@ # Setup configure Configuring Reexport2-1.0... -Error: cabal: Duplicate modules in library: Asdf +Error: [Cabal-5559] +Duplicate modules in library: Asdf diff --git a/cabal-testsuite/PackageTests/Backpack/Reexport2/setup.out b/cabal-testsuite/PackageTests/Backpack/Reexport2/setup.out index 58f2330e0d3..75bc0f494a7 100644 --- a/cabal-testsuite/PackageTests/Backpack/Reexport2/setup.out +++ b/cabal-testsuite/PackageTests/Backpack/Reexport2/setup.out @@ -1,3 +1,4 @@ # Setup configure Configuring Reexport2-1.0... -Error: setup: Duplicate modules in library: Asdf +Error: [Cabal-5559] +Duplicate modules in library: Asdf diff --git a/cabal-testsuite/PackageTests/BuildDeps/InternalLibrary0/setup.cabal.out b/cabal-testsuite/PackageTests/BuildDeps/InternalLibrary0/setup.cabal.out index 14aba5dcbbb..391531a89e2 100644 --- a/cabal-testsuite/PackageTests/BuildDeps/InternalLibrary0/setup.cabal.out +++ b/cabal-testsuite/PackageTests/BuildDeps/InternalLibrary0/setup.cabal.out @@ -1,3 +1,4 @@ # Setup configure Configuring InternalLibrary0-0.1... -Error: cabal: The field 'build-depends: InternalLibrary0' refers to a library which is defined within the same package. To use this feature the package must specify at least 'cabal-version: >= 1.8'. +Error: [Cabal-7007] +The field 'build-depends: InternalLibrary0' refers to a library which is defined within the same package. To use this feature the package must specify at least 'cabal-version: >= 1.8'. diff --git a/cabal-testsuite/PackageTests/BuildDeps/InternalLibrary0/setup.out b/cabal-testsuite/PackageTests/BuildDeps/InternalLibrary0/setup.out index 0a464192dc9..391531a89e2 100644 --- a/cabal-testsuite/PackageTests/BuildDeps/InternalLibrary0/setup.out +++ b/cabal-testsuite/PackageTests/BuildDeps/InternalLibrary0/setup.out @@ -1,3 +1,4 @@ # Setup configure Configuring InternalLibrary0-0.1... -Error: setup: The field 'build-depends: InternalLibrary0' refers to a library which is defined within the same package. To use this feature the package must specify at least 'cabal-version: >= 1.8'. +Error: [Cabal-7007] +The field 'build-depends: InternalLibrary0' refers to a library which is defined within the same package. To use this feature the package must specify at least 'cabal-version: >= 1.8'. diff --git a/cabal-testsuite/PackageTests/BuildToolDependsInternalMissing/setup.cabal.out b/cabal-testsuite/PackageTests/BuildToolDependsInternalMissing/setup.cabal.out index 059c3214d71..da5c074772e 100644 --- a/cabal-testsuite/PackageTests/BuildToolDependsInternalMissing/setup.cabal.out +++ b/cabal-testsuite/PackageTests/BuildToolDependsInternalMissing/setup.cabal.out @@ -1,3 +1,4 @@ # Setup configure Configuring build-tool-depends-missing-0.1.0.0... -Error: cabal: The package depends on a missing internal executable: build-tool-depends-missing:hello-world \ No newline at end of file +Error: [Cabal-5559] +The package depends on a missing internal executable: build-tool-depends-missing:hello-world diff --git a/cabal-testsuite/PackageTests/BuildToolDependsInternalMissing/setup.out b/cabal-testsuite/PackageTests/BuildToolDependsInternalMissing/setup.out index 861f95ddeb8..da5c074772e 100644 --- a/cabal-testsuite/PackageTests/BuildToolDependsInternalMissing/setup.out +++ b/cabal-testsuite/PackageTests/BuildToolDependsInternalMissing/setup.out @@ -1,3 +1,4 @@ # Setup configure Configuring build-tool-depends-missing-0.1.0.0... -Error: setup: The package depends on a missing internal executable: build-tool-depends-missing:hello-world +Error: [Cabal-5559] +The package depends on a missing internal executable: build-tool-depends-missing:hello-world diff --git a/cabal-testsuite/PackageTests/ConfigureComponent/SubLib/setup-explicit-fail.out b/cabal-testsuite/PackageTests/ConfigureComponent/SubLib/setup-explicit-fail.out index 3726ef6fb23..fec347864e5 100644 --- a/cabal-testsuite/PackageTests/ConfigureComponent/SubLib/setup-explicit-fail.out +++ b/cabal-testsuite/PackageTests/ConfigureComponent/SubLib/setup-explicit-fail.out @@ -9,5 +9,6 @@ Installing internal library sublib in Registering library 'sublib' for Lib-0.1.0.0... # Setup configure Configuring executable 'exe' for Lib-0.1.0.0... -Error: setup: Encountered missing or private dependencies: +Error: [Cabal-8010] +Encountered missing or private dependencies: Lib:sublib diff --git a/cabal-testsuite/PackageTests/InternalVersions/BuildDependsBad/setup.cabal.out b/cabal-testsuite/PackageTests/InternalVersions/BuildDependsBad/setup.cabal.out index 843f2e7808a..b03e6765cb0 100644 --- a/cabal-testsuite/PackageTests/InternalVersions/BuildDependsBad/setup.cabal.out +++ b/cabal-testsuite/PackageTests/InternalVersions/BuildDependsBad/setup.cabal.out @@ -1,3 +1,4 @@ # Setup configure Configuring build-depends-bad-version-0.1.0.0... -Error: cabal: The package has an impossible version range for a dependency on an internal library: build-depends-bad-version >=2. This version range does not include the current package, and must be removed as the current package's library will always be used. +Error: [Cabal-5559] +The package has an impossible version range for a dependency on an internal library: build-depends-bad-version >=2. This version range does not include the current package, and must be removed as the current package's library will always be used. diff --git a/cabal-testsuite/PackageTests/InternalVersions/BuildDependsBad/setup.out b/cabal-testsuite/PackageTests/InternalVersions/BuildDependsBad/setup.out index e0b6883000a..b03e6765cb0 100644 --- a/cabal-testsuite/PackageTests/InternalVersions/BuildDependsBad/setup.out +++ b/cabal-testsuite/PackageTests/InternalVersions/BuildDependsBad/setup.out @@ -1,3 +1,4 @@ # Setup configure Configuring build-depends-bad-version-0.1.0.0... -Error: setup: The package has an impossible version range for a dependency on an internal library: build-depends-bad-version >=2. This version range does not include the current package, and must be removed as the current package's library will always be used. +Error: [Cabal-5559] +The package has an impossible version range for a dependency on an internal library: build-depends-bad-version >=2. This version range does not include the current package, and must be removed as the current package's library will always be used. diff --git a/cabal-testsuite/PackageTests/InternalVersions/BuildToolDependsBad/setup.cabal.out b/cabal-testsuite/PackageTests/InternalVersions/BuildToolDependsBad/setup.cabal.out index d92e9e784e5..077f750b066 100644 --- a/cabal-testsuite/PackageTests/InternalVersions/BuildToolDependsBad/setup.cabal.out +++ b/cabal-testsuite/PackageTests/InternalVersions/BuildToolDependsBad/setup.cabal.out @@ -1,3 +1,4 @@ # Setup configure Configuring build-tool-depends-bad-version-0.1.0.0... -Error: cabal: The package has an impossible version range for a dependency on an internal executable: build-tool-depends-bad-version:hello-world >=2. This version range does not include the current package, and must be removed as the current package's executable will always be used. +Error: [Cabal-5559] +The package has an impossible version range for a dependency on an internal executable: build-tool-depends-bad-version:hello-world >=2. This version range does not include the current package, and must be removed as the current package's executable will always be used. diff --git a/cabal-testsuite/PackageTests/InternalVersions/BuildToolDependsBad/setup.out b/cabal-testsuite/PackageTests/InternalVersions/BuildToolDependsBad/setup.out index eeb1226a74f..077f750b066 100644 --- a/cabal-testsuite/PackageTests/InternalVersions/BuildToolDependsBad/setup.out +++ b/cabal-testsuite/PackageTests/InternalVersions/BuildToolDependsBad/setup.out @@ -1,3 +1,4 @@ # Setup configure Configuring build-tool-depends-bad-version-0.1.0.0... -Error: setup: The package has an impossible version range for a dependency on an internal executable: build-tool-depends-bad-version:hello-world >=2. This version range does not include the current package, and must be removed as the current package's executable will always be used. +Error: [Cabal-5559] +The package has an impossible version range for a dependency on an internal executable: build-tool-depends-bad-version:hello-world >=2. This version range does not include the current package, and must be removed as the current package's executable will always be used. diff --git a/cabal-testsuite/PackageTests/InternalVersions/BuildToolsBad/setup.cabal.out b/cabal-testsuite/PackageTests/InternalVersions/BuildToolsBad/setup.cabal.out index 44f43d8b30b..68a45e22992 100644 --- a/cabal-testsuite/PackageTests/InternalVersions/BuildToolsBad/setup.cabal.out +++ b/cabal-testsuite/PackageTests/InternalVersions/BuildToolsBad/setup.cabal.out @@ -1,3 +1,4 @@ # Setup configure Configuring build-tools-bad-version-0.1.0.0... -Error: cabal: The package has an impossible version range for a dependency on an internal executable: build-tools-bad-version:hello-world >=2. This version range does not include the current package, and must be removed as the current package's executable will always be used. +Error: [Cabal-5559] +The package has an impossible version range for a dependency on an internal executable: build-tools-bad-version:hello-world >=2. This version range does not include the current package, and must be removed as the current package's executable will always be used. diff --git a/cabal-testsuite/PackageTests/InternalVersions/BuildToolsBad/setup.out b/cabal-testsuite/PackageTests/InternalVersions/BuildToolsBad/setup.out index 06aaa652bce..68a45e22992 100644 --- a/cabal-testsuite/PackageTests/InternalVersions/BuildToolsBad/setup.out +++ b/cabal-testsuite/PackageTests/InternalVersions/BuildToolsBad/setup.out @@ -1,3 +1,4 @@ # Setup configure Configuring build-tools-bad-version-0.1.0.0... -Error: setup: The package has an impossible version range for a dependency on an internal executable: build-tools-bad-version:hello-world >=2. This version range does not include the current package, and must be removed as the current package's executable will always be used. +Error: [Cabal-5559] +The package has an impossible version range for a dependency on an internal executable: build-tools-bad-version:hello-world >=2. This version range does not include the current package, and must be removed as the current package's executable will always be used. From 1bd3f068c3761725f59916238bd20ab6605ea0d3 Mon Sep 17 00:00:00 2001 From: SuganyaAK Date: Wed, 9 Aug 2023 11:44:38 -0400 Subject: [PATCH 08/16] Changed to "GetProgramInvocationException" and "SanityCheckForEnableComponents" --- Cabal/src/Distribution/Simple/Configure.hs | 2 +- Cabal/src/Distribution/Simple/Errors.hs | 12 ++++++------ Cabal/src/Distribution/Simple/Program/Run.hs | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cabal/src/Distribution/Simple/Configure.hs b/Cabal/src/Distribution/Simple/Configure.hs index 29de051b3ea..5a073ac74fa 100644 --- a/Cabal/src/Distribution/Simple/Configure.hs +++ b/Cabal/src/Distribution/Simple/Configure.hs @@ -509,7 +509,7 @@ configure (pkg_descr0, pbi) cfg = do ( isJust mb_cname && (fromFlag (configTests cfg) || fromFlag (configBenchmarks cfg)) ) - $ dieWithException verbosity SanitycheckForEnableComponents + $ dieWithException verbosity SanityCheckForEnableComponents -- Some sanity checks related to dynamic/static linking. when (fromFlag (configDynExe cfg) && fromFlag (configFullyStaticExe cfg)) $ diff --git a/Cabal/src/Distribution/Simple/Errors.hs b/Cabal/src/Distribution/Simple/Errors.hs index c643bb8b0b4..2aab2559177 100644 --- a/Cabal/src/Distribution/Simple/Errors.hs +++ b/Cabal/src/Distribution/Simple/Errors.hs @@ -109,7 +109,7 @@ data CabalException | NoSupportPreProcessingBenchmarkExtras BenchmarkType | UnlitException String | RunProgramInvocationException FilePath String - | GetProgamInvocationException FilePath String + | GetProgramInvocationException FilePath String | GetProgramInvocationLBSException FilePath String | CheckSemaphoreSupport | NoLibraryForPackage @@ -118,7 +118,7 @@ data CabalException | NoValidComponent | ConfigureEitherSingleOrAll | ConfigCIDValidForPreComponent - | SanitycheckForEnableComponents + | SanityCheckForEnableComponents | SanityCheckForDynamicStaticLinking | UnsupportedLanguages PackageIdentifier CompilerId [String] | UnsupportedLanguageExtension PackageIdentifier CompilerId [String] @@ -214,7 +214,7 @@ exceptionCode e = case e of NoSupportPreProcessingBenchmarkExtras{} -> 9999 UnlitException{} -> 5454 RunProgramInvocationException{} -> 8012 - GetProgamInvocationException{} -> 7300 + GetProgramInvocationException{} -> 7300 GetProgramInvocationLBSException{} -> 6578 CheckSemaphoreSupport{} -> 2002 NoLibraryForPackage{} -> 8004 @@ -223,7 +223,7 @@ exceptionCode e = case e of NoValidComponent{} -> 5680 ConfigureEitherSingleOrAll{} -> 2001 ConfigCIDValidForPreComponent{} -> 7006 - SanitycheckForEnableComponents{} -> 5004 + SanityCheckForEnableComponents{} -> 5004 SanityCheckForDynamicStaticLinking{} -> 4007 UnsupportedLanguages{} -> 8074 UnsupportedLanguageExtension{} -> 5656 @@ -439,7 +439,7 @@ exceptionMessage e = case e of ++ prettyShow tt UnlitException str -> str RunProgramInvocationException path errors -> "'" ++ path ++ "' exited with an error:\n" ++ errors - GetProgamInvocationException path errors -> "'" ++ path ++ "' exited with an error:\n" ++ errors + GetProgramInvocationException path errors -> "'" ++ path ++ "' exited with an error:\n" ++ errors GetProgramInvocationLBSException path errors -> "'" ++ path ++ "' exited with an error:\n" ++ errors CheckSemaphoreSupport -> "Your compiler does not support the -jsem flag. " @@ -456,7 +456,7 @@ exceptionMessage e = case e of NoValidComponent -> "No valid component targets found" ConfigureEitherSingleOrAll -> "Can only configure either single component or all of them" ConfigCIDValidForPreComponent -> "--cid is only supported for per-component configure" - SanitycheckForEnableComponents -> + SanityCheckForEnableComponents -> "--enable-tests/--enable-benchmarks are incompatible with" ++ " explicitly specifying a component to configure." SanityCheckForDynamicStaticLinking -> diff --git a/Cabal/src/Distribution/Simple/Program/Run.hs b/Cabal/src/Distribution/Simple/Program/Run.hs index 927af778a88..c5479df03a9 100644 --- a/Cabal/src/Distribution/Simple/Program/Run.hs +++ b/Cabal/src/Distribution/Simple/Program/Run.hs @@ -167,7 +167,7 @@ getProgramInvocationOutput verbosity inv = do (output, errors, exitCode) <- getProgramInvocationOutputAndErrors verbosity inv when (exitCode /= ExitSuccess) $ dieWithException verbosity $ - GetProgamInvocationException (progInvokePath inv) errors + GetProgramInvocationException (progInvokePath inv) errors return output getProgramInvocationLBS :: Verbosity -> ProgramInvocation -> IO LBS.ByteString From e834da93c298954aa2cf553480ae7547d377c9f8 Mon Sep 17 00:00:00 2001 From: SuganyaAK Date: Wed, 9 Aug 2023 14:29:39 -0400 Subject: [PATCH 09/16] Going back to former die' call in `getProgramInvocationOutout` function to check on the failing CI test --- Cabal/src/Distribution/Simple/Program/Run.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Cabal/src/Distribution/Simple/Program/Run.hs b/Cabal/src/Distribution/Simple/Program/Run.hs index c5479df03a9..f1ad72fec25 100644 --- a/Cabal/src/Distribution/Simple/Program/Run.hs +++ b/Cabal/src/Distribution/Simple/Program/Run.hs @@ -166,8 +166,10 @@ getProgramInvocationOutput :: Verbosity -> ProgramInvocation -> IO String getProgramInvocationOutput verbosity inv = do (output, errors, exitCode) <- getProgramInvocationOutputAndErrors verbosity inv when (exitCode /= ExitSuccess) $ - dieWithException verbosity $ - GetProgramInvocationException (progInvokePath inv) errors + die' verbosity $ + "'" ++ progInvokePath inv ++ "' exited with an error:\n" ++ errors + -- dieWithException verbosity $ + -- GetProgramInvocationException (progInvokePath inv) errors return output getProgramInvocationLBS :: Verbosity -> ProgramInvocation -> IO LBS.ByteString From f8fea52aed6a348639a4e9c385b735be359cd0fb Mon Sep 17 00:00:00 2001 From: SuganyaAK Date: Wed, 9 Aug 2023 22:19:33 -0400 Subject: [PATCH 10/16] Accepted new error output, included cabalexception in handler --- Cabal/src/Distribution/Simple/Errors.hs | 2 +- .../PackageTests/PackageDB/cabal-fail-no-packagedbs.out | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Cabal/src/Distribution/Simple/Errors.hs b/Cabal/src/Distribution/Simple/Errors.hs index 2aab2559177..d13a94786d8 100644 --- a/Cabal/src/Distribution/Simple/Errors.hs +++ b/Cabal/src/Distribution/Simple/Errors.hs @@ -236,7 +236,7 @@ exceptionCode e = case e of CompilerDoesntSupportBackpack{} -> 5446 LibraryWithinSamePackage{} -> 7007 ReportFailedDependencies{} -> 4321 - NoPackageDatabaseSpecified{} -> 2002 + NoPackageDatabaseSpecified{} -> 2300 HowToFindInstalledPackages{} -> 3003 PkgConfigNotFound{} -> 7123 BadVersion{} -> 7600 diff --git a/cabal-testsuite/PackageTests/PackageDB/cabal-fail-no-packagedbs.out b/cabal-testsuite/PackageTests/PackageDB/cabal-fail-no-packagedbs.out index dabae31b77d..5697c77102c 100644 --- a/cabal-testsuite/PackageTests/PackageDB/cabal-fail-no-packagedbs.out +++ b/cabal-testsuite/PackageTests/PackageDB/cabal-fail-no-packagedbs.out @@ -1,2 +1,3 @@ # cabal v2-build -Error: cabal: No package databases have been specified. If you use --package-db=clear, you must follow it with --package-db= with 'global', 'user' or a specific file. +Error: [Cabal-2300] +No package databases have been specified. If you use --package-db=clear, you must follow it with --package-db= with 'global', 'user' or a specific file. From d9003cbf4fe235cfa58fdc130f028088a86102ef Mon Sep 17 00:00:00 2001 From: SuganyaAK Date: Wed, 9 Aug 2023 22:20:37 -0400 Subject: [PATCH 11/16] Error code rectification --- Cabal/src/Distribution/Simple/Errors.hs | 4 ++-- Cabal/src/Distribution/Simple/Program/Run.hs | 8 ++++---- cabal-install/src/Distribution/Client/ProjectBuilding.hs | 3 +++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Cabal/src/Distribution/Simple/Errors.hs b/Cabal/src/Distribution/Simple/Errors.hs index d13a94786d8..28192e6ddef 100644 --- a/Cabal/src/Distribution/Simple/Errors.hs +++ b/Cabal/src/Distribution/Simple/Errors.hs @@ -175,7 +175,7 @@ exceptionCode e = case e of NoGHCVersionFromCompiler -> 4098 HaddockAndGHCVersionDoesntMatch{} -> 1998 MustHaveSharedLibraries{} -> 6032 - HaddockPackageFlags{} -> 4567 + HaddockPackageFlags{} -> 4569 UnknownCompilerFlavor{} -> 3102 FailedToDetermineTarget{} -> 5049 NoMultipleTargets{} -> 6091 @@ -185,7 +185,7 @@ exceptionCode e = case e of BuildingNotSupportedWithCompiler{} -> 7077 ProvideHaskellSuiteTool{} -> 7509 CannotDetermineCompilerVersion{} -> 4519 - PkgDumpFailed{} -> 2290 + PkgDumpFailed{} -> 2291 FailedToParseOutput{} -> 5500 CantFindSourceModule{} -> 8870 VersionMismatchJS{} -> 9001 diff --git a/Cabal/src/Distribution/Simple/Program/Run.hs b/Cabal/src/Distribution/Simple/Program/Run.hs index f1ad72fec25..22846d8b171 100644 --- a/Cabal/src/Distribution/Simple/Program/Run.hs +++ b/Cabal/src/Distribution/Simple/Program/Run.hs @@ -166,10 +166,10 @@ getProgramInvocationOutput :: Verbosity -> ProgramInvocation -> IO String getProgramInvocationOutput verbosity inv = do (output, errors, exitCode) <- getProgramInvocationOutputAndErrors verbosity inv when (exitCode /= ExitSuccess) $ - die' verbosity $ - "'" ++ progInvokePath inv ++ "' exited with an error:\n" ++ errors - -- dieWithException verbosity $ - -- GetProgramInvocationException (progInvokePath inv) errors + -- die' verbosity $ + -- "'" ++ progInvokePath inv ++ "' exited with an error:\n" ++ errors + dieWithException verbosity $ + GetProgramInvocationException (progInvokePath inv) errors return output getProgramInvocationLBS :: Verbosity -> ProgramInvocation -> IO LBS.ByteString diff --git a/cabal-install/src/Distribution/Client/ProjectBuilding.hs b/cabal-install/src/Distribution/Client/ProjectBuilding.hs index a47cad5203e..8e553aca511 100644 --- a/cabal-install/src/Distribution/Client/ProjectBuilding.hs +++ b/cabal-install/src/Distribution/Client/ProjectBuilding.hs @@ -132,6 +132,7 @@ import System.IO (Handle, IOMode (AppendMode), withFile) import System.Semaphore (SemaphoreName (..)) import Distribution.Compat.Directory (listDirectory) +import Distribution.Simple.Errors () import Distribution.Simple.Flag (fromFlagOrDefault) ------------------------------------------------------------------------------ @@ -1882,6 +1883,8 @@ annotateFailure mlogFile annotate action = Handler $ \async -> throwIO (async :: SomeAsyncException) #else Handler $ \async -> throwIO (async :: AsyncException) +#elseif + Handler $ \cabexe -> throwIO (cabexe :: VerboseException CabalException) #endif , Handler $ \other -> handler (other :: SomeException) ] From 1d754361162b712785df14c264de4665368ef5ff Mon Sep 17 00:00:00 2001 From: SuganyaAK Date: Thu, 10 Aug 2023 04:14:29 -0400 Subject: [PATCH 12/16] Added a handler condition for VerboseException CabalException in `annotaeFailure` function --- Cabal/src/Distribution/Simple/Utils.hs | 1 + cabal-install/src/Distribution/Client/ProjectBuilding.hs | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Cabal/src/Distribution/Simple/Utils.hs b/Cabal/src/Distribution/Simple/Utils.hs index a2273ac9630..7d5a00d523b 100644 --- a/Cabal/src/Distribution/Simple/Utils.hs +++ b/Cabal/src/Distribution/Simple/Utils.hs @@ -78,6 +78,7 @@ module Distribution.Simple.Utils , IOData (..) , KnownIODataMode (..) , IODataMode (..) + , VerboseException (..) -- * copying files , createDirectoryIfMissingVerbose diff --git a/cabal-install/src/Distribution/Client/ProjectBuilding.hs b/cabal-install/src/Distribution/Client/ProjectBuilding.hs index 8e553aca511..e4650e4fbe4 100644 --- a/cabal-install/src/Distribution/Client/ProjectBuilding.hs +++ b/cabal-install/src/Distribution/Client/ProjectBuilding.hs @@ -132,8 +132,9 @@ import System.IO (Handle, IOMode (AppendMode), withFile) import System.Semaphore (SemaphoreName (..)) import Distribution.Compat.Directory (listDirectory) -import Distribution.Simple.Errors () +import Distribution.Simple.Errors (CabalException) import Distribution.Simple.Flag (fromFlagOrDefault) +import Distribution.Simple.Utils () ------------------------------------------------------------------------------ @@ -1883,9 +1884,8 @@ annotateFailure mlogFile annotate action = Handler $ \async -> throwIO (async :: SomeAsyncException) #else Handler $ \async -> throwIO (async :: AsyncException) -#elseif - Handler $ \cabexe -> throwIO (cabexe :: VerboseException CabalException) #endif + , Handler $ \cabexe -> handler (cabexe :: VerboseException CabalException) , Handler $ \other -> handler (other :: SomeException) ] where From 331924e6bfb0bdda5d1745349b0b4cd9effe03ae Mon Sep 17 00:00:00 2001 From: SuganyaAK Date: Thu, 10 Aug 2023 05:21:33 -0400 Subject: [PATCH 13/16] Leaving "GetProgramInvocationException" unmodified --- Cabal/src/Distribution/Simple/Program/Run.hs | 8 ++++---- Cabal/src/Distribution/Simple/Utils.hs | 1 - cabal-install/src/Distribution/Client/ProjectBuilding.hs | 3 --- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Cabal/src/Distribution/Simple/Program/Run.hs b/Cabal/src/Distribution/Simple/Program/Run.hs index 22846d8b171..f1ad72fec25 100644 --- a/Cabal/src/Distribution/Simple/Program/Run.hs +++ b/Cabal/src/Distribution/Simple/Program/Run.hs @@ -166,10 +166,10 @@ getProgramInvocationOutput :: Verbosity -> ProgramInvocation -> IO String getProgramInvocationOutput verbosity inv = do (output, errors, exitCode) <- getProgramInvocationOutputAndErrors verbosity inv when (exitCode /= ExitSuccess) $ - -- die' verbosity $ - -- "'" ++ progInvokePath inv ++ "' exited with an error:\n" ++ errors - dieWithException verbosity $ - GetProgramInvocationException (progInvokePath inv) errors + die' verbosity $ + "'" ++ progInvokePath inv ++ "' exited with an error:\n" ++ errors + -- dieWithException verbosity $ + -- GetProgramInvocationException (progInvokePath inv) errors return output getProgramInvocationLBS :: Verbosity -> ProgramInvocation -> IO LBS.ByteString diff --git a/Cabal/src/Distribution/Simple/Utils.hs b/Cabal/src/Distribution/Simple/Utils.hs index 7d5a00d523b..a2273ac9630 100644 --- a/Cabal/src/Distribution/Simple/Utils.hs +++ b/Cabal/src/Distribution/Simple/Utils.hs @@ -78,7 +78,6 @@ module Distribution.Simple.Utils , IOData (..) , KnownIODataMode (..) , IODataMode (..) - , VerboseException (..) -- * copying files , createDirectoryIfMissingVerbose diff --git a/cabal-install/src/Distribution/Client/ProjectBuilding.hs b/cabal-install/src/Distribution/Client/ProjectBuilding.hs index e4650e4fbe4..a47cad5203e 100644 --- a/cabal-install/src/Distribution/Client/ProjectBuilding.hs +++ b/cabal-install/src/Distribution/Client/ProjectBuilding.hs @@ -132,9 +132,7 @@ import System.IO (Handle, IOMode (AppendMode), withFile) import System.Semaphore (SemaphoreName (..)) import Distribution.Compat.Directory (listDirectory) -import Distribution.Simple.Errors (CabalException) import Distribution.Simple.Flag (fromFlagOrDefault) -import Distribution.Simple.Utils () ------------------------------------------------------------------------------ @@ -1885,7 +1883,6 @@ annotateFailure mlogFile annotate action = #else Handler $ \async -> throwIO (async :: AsyncException) #endif - , Handler $ \cabexe -> handler (cabexe :: VerboseException CabalException) , Handler $ \other -> handler (other :: SomeException) ] where From 30ad07f3a573167260a9a784e3e86dcf3c67595a Mon Sep 17 00:00:00 2001 From: SuganyaAK Date: Thu, 10 Aug 2023 11:48:52 -0400 Subject: [PATCH 14/16] Incorporated review comments --- .../Distribution/PackageDescription/Check.hs | 4 +- Cabal/src/Distribution/Simple/Build.hs | 3 +- Cabal/src/Distribution/Simple/Configure.hs | 38 ++++--------------- Cabal/src/Distribution/Simple/Errors.hs | 18 ++++----- Cabal/src/Distribution/Simple/Program/Run.hs | 2 - 5 files changed, 19 insertions(+), 46 deletions(-) diff --git a/Cabal/src/Distribution/PackageDescription/Check.hs b/Cabal/src/Distribution/PackageDescription/Check.hs index 4c2701d95c3..3218ba97e54 100644 --- a/Cabal/src/Distribution/PackageDescription/Check.hs +++ b/Cabal/src/Distribution/PackageDescription/Check.hs @@ -309,9 +309,9 @@ ppExplanation SignaturesCabal2 = "To use the 'signatures' field the package needs to specify " ++ "at least 'cabal-version: 2.0'." ppExplanation AutogenNotExposed = - "An 'autogen-module' is neither on 'exposed-modules' or 'other-modules'." + "An 'autogen-module' is neither on 'exposed-modules' nor 'other-modules'." ppExplanation AutogenIncludesNotIncluded = - "An include in 'autogen-includes' is neither in 'includes' or " + "An include in 'autogen-includes' is neither in 'includes' nor " ++ "'install-includes'." ppExplanation (NoMainIs exe) = "No 'main-is' field found for executable " ++ prettyShow (exeName exe) diff --git a/Cabal/src/Distribution/Simple/Build.hs b/Cabal/src/Distribution/Simple/Build.hs index c5633c159d2..893ca24e187 100644 --- a/Cabal/src/Distribution/Simple/Build.hs +++ b/Cabal/src/Distribution/Simple/Build.hs @@ -181,8 +181,7 @@ checkSemaphoreSupport :: Verbosity -> Compiler -> BuildFlags -> IO () checkSemaphoreSupport verbosity comp flags = do unless (jsemSupported comp || (isNothing (flagToMaybe (buildUseSemaphore flags)))) $ - dieWithException verbosity $ - CheckSemaphoreSupport + dieWithException verbosity CheckSemaphoreSupport -- | Write available build information for 'LocalBuildInfo' to disk. -- diff --git a/Cabal/src/Distribution/Simple/Configure.hs b/Cabal/src/Distribution/Simple/Configure.hs index 5a073ac74fa..f35f98f4fcb 100644 --- a/Cabal/src/Distribution/Simple/Configure.hs +++ b/Cabal/src/Distribution/Simple/Configure.hs @@ -422,10 +422,7 @@ configure (pkg_descr0, pbi) cfg = do _ | null (configArgs cfg) -> return Nothing [cname] -> return (Just cname) [] -> dieWithException verbosity NoValidComponent - _ -> - dieWithException - verbosity - ConfigureEitherSingleOrAll + _ -> dieWithException verbosity ConfigureEitherSingleOrAll let use_external_internal_deps = isJust mb_cname case mb_cname of @@ -513,8 +510,7 @@ configure (pkg_descr0, pbi) cfg = do -- Some sanity checks related to dynamic/static linking. when (fromFlag (configDynExe cfg) && fromFlag (configFullyStaticExe cfg)) $ - dieWithException verbosity $ - SanityCheckForDynamicStaticLinking + dieWithException verbosity SanityCheckForDynamicStaticLinking -- allConstraints: The set of all 'Dependency's we have. Used ONLY -- to 'configureFinalizedPackage'. @@ -1298,20 +1294,17 @@ checkCompilerProblems verbosity comp pkg_descr enabled = do (all (isDefaultIncludeRenaming . mixinIncludeRenaming) . mixins) (enabledBuildInfos pkg_descr enabled) ) - $ dieWithException verbosity - $ CompilerDoesntSupportThinning + $ dieWithException verbosity CompilerDoesn'tSupportThinning when ( any (not . null . reexportedModules) (allLibraries pkg_descr) && not (reexportedModulesSupported comp) ) - $ dieWithException verbosity - $ CompilerDoesntSupportReexports + $ dieWithException verbosity CompilerDoesn'tSupportReexports when ( any (not . null . signatures) (allLibraries pkg_descr) && not (backpackSupported comp) ) - $ dieWithException verbosity - $ CompilerDoesntSupportBackpack + $ dieWithException verbosity CompilerDoesn'tSupportBackpack -- | Select dependencies for the package. configureDependencies @@ -1564,11 +1557,6 @@ data DependencyResolution -- polymorphism out of the 'Package' typeclass.) InternalDependency PackageId --- data FailedDependency --- = DependencyNotExists PackageName --- | DependencyMissingInternal PackageName LibraryName --- | DependencyNoVersion Dependency - -- | Test for a package dependency and record the version we have installed. selectDependency :: PackageId @@ -1692,8 +1680,7 @@ getInstalledPackages -> IO InstalledPackageIndex getInstalledPackages verbosity comp packageDBs progdb = do when (null packageDBs) $ - dieWithException verbosity $ - NoPackageDatabaseSpecified + dieWithException verbosity NoPackageDatabaseSpecified info verbosity "Reading installed packages..." -- do not check empty packagedbs (ghc-pkg would error out) @@ -1803,10 +1790,6 @@ combinedConstraints constraints dependencies installedPackages = do when (not (null badComponentIds)) $ Left $ CombinedConstraints (dispDependencies badComponentIds) - -- (render $ - -- text "The following package dependencies were requested" - -- $+$ nest 4 (dispDependencies badComponentIds) - -- $+$ text "however the given installed package instance does not exist." ) -- TODO: we don't check that all dependencies are used! @@ -2293,7 +2276,7 @@ checkForeignDeps pkg lbi verbosity = explainErrors Nothing [] = return () -- should be impossible! explainErrors _ _ | isNothing . lookupProgram gccProgram . withPrograms $ lbi = - dieWithException verbosity $ NoWorkingGcc + dieWithException verbosity NoWorkingGcc explainErrors hdr libs = dieWithException verbosity $ ExplainErrors hdr libs @@ -2403,7 +2386,6 @@ checkRelocatable verbosity pkg lbi = unless (p `isPrefixOf` canonicalized) $ dieWithException verbosity $ LibDirDepsPrefixNotRelative libdir p - -- msg libdir | otherwise = return () -- NB: should be good enough to check this against the default @@ -2413,12 +2395,6 @@ checkRelocatable verbosity pkg lbi = p = prefix installDirs ipkgs = PackageIndex.allPackages (installedPkgs lbi) -{- msg l = - "Library directory of a dependency: " - ++ show l - ++ "\nis not relative to the installation prefix:\n" - ++ show p-} - -- ----------------------------------------------------------------------------- -- Testing foreign library requirements diff --git a/Cabal/src/Distribution/Simple/Errors.hs b/Cabal/src/Distribution/Simple/Errors.hs index 28192e6ddef..fb1c2875f1c 100644 --- a/Cabal/src/Distribution/Simple/Errors.hs +++ b/Cabal/src/Distribution/Simple/Errors.hs @@ -126,9 +126,9 @@ data CabalException | ExpectedAbsoluteDirectory FilePath | FlagsNotSpecified [FlagName] | EncounteredMissingDependency [Dependency] - | CompilerDoesntSupportThinning - | CompilerDoesntSupportReexports - | CompilerDoesntSupportBackpack + | CompilerDoesn'tSupportThinning + | CompilerDoesn'tSupportReexports + | CompilerDoesn'tSupportBackpack | LibraryWithinSamePackage [PackageId] | ReportFailedDependencies [FailedDependency] String | NoPackageDatabaseSpecified @@ -231,9 +231,9 @@ exceptionCode e = case e of ExpectedAbsoluteDirectory{} -> 6662 FlagsNotSpecified{} -> 9080 EncounteredMissingDependency{} -> 8010 - CompilerDoesntSupportThinning{} -> 4003 - CompilerDoesntSupportReexports{} -> 3456 - CompilerDoesntSupportBackpack{} -> 5446 + CompilerDoesn'tSupportThinning{} -> 4003 + CompilerDoesn'tSupportReexports{} -> 3456 + CompilerDoesn'tSupportBackpack{} -> 5446 LibraryWithinSamePackage{} -> 7007 ReportFailedDependencies{} -> 4321 NoPackageDatabaseSpecified{} -> 2300 @@ -495,14 +495,14 @@ exceptionMessage e = case e of . map (pretty . simplifyDependency) $ missing ) - CompilerDoesntSupportThinning -> + CompilerDoesn'tSupportThinning -> "Your compiler does not support thinning and renaming on " ++ "package flags. To use this feature you must use " ++ "GHC 7.9 or later." - CompilerDoesntSupportReexports -> + CompilerDoesn'tSupportReexports -> "Your compiler does not support module re-exports. To use " ++ "this feature you must use GHC 7.9 or later." - CompilerDoesntSupportBackpack -> + CompilerDoesn'tSupportBackpack -> "Your compiler does not support Backpack. To use " ++ "this feature you must use GHC 8.1 or later." LibraryWithinSamePackage internalPkgDeps -> diff --git a/Cabal/src/Distribution/Simple/Program/Run.hs b/Cabal/src/Distribution/Simple/Program/Run.hs index f1ad72fec25..27ff33dce01 100644 --- a/Cabal/src/Distribution/Simple/Program/Run.hs +++ b/Cabal/src/Distribution/Simple/Program/Run.hs @@ -168,8 +168,6 @@ getProgramInvocationOutput verbosity inv = do when (exitCode /= ExitSuccess) $ die' verbosity $ "'" ++ progInvokePath inv ++ "' exited with an error:\n" ++ errors - -- dieWithException verbosity $ - -- GetProgramInvocationException (progInvokePath inv) errors return output getProgramInvocationLBS :: Verbosity -> ProgramInvocation -> IO LBS.ByteString From e3fdde3b39af95c443e3ade81b00b71cd5da0ccb Mon Sep 17 00:00:00 2001 From: SuganyaAK Date: Thu, 10 Aug 2023 12:23:07 -0400 Subject: [PATCH 15/16] Updated "nor" in AutoGenModule test case --- .../PackageTests/AutogenModules/Package/setup.cabal.out | 4 ++-- cabal-testsuite/PackageTests/AutogenModules/Package/setup.out | 4 ++-- .../PackageTests/AutogenModules/Package/setup.test.hs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cabal-testsuite/PackageTests/AutogenModules/Package/setup.cabal.out b/cabal-testsuite/PackageTests/AutogenModules/Package/setup.cabal.out index d75804e0c8f..dd76b493185 100644 --- a/cabal-testsuite/PackageTests/AutogenModules/Package/setup.cabal.out +++ b/cabal-testsuite/PackageTests/AutogenModules/Package/setup.cabal.out @@ -1,7 +1,7 @@ # Setup configure Configuring AutogenModules-0.1... Error: [Cabal-5559] -An 'autogen-module' is neither on 'exposed-modules' or 'other-modules'. +An 'autogen-module' is neither on 'exposed-modules' nor 'other-modules'. On executable 'Exe' an 'autogen-module' is not on 'other-modules' @@ -10,7 +10,7 @@ On test suite 'Test' an 'autogen-module' is not on 'other-modules' On benchmark 'Bench' an 'autogen-module' is not on 'other-modules' # Setup sdist Distribution quality errors: -An 'autogen-module' is neither on 'exposed-modules' or 'other-modules'. +An 'autogen-module' is neither on 'exposed-modules' nor 'other-modules'. On executable 'Exe' an 'autogen-module' is not on 'other-modules' On test suite 'Test' an 'autogen-module' is not on 'other-modules' On benchmark 'Bench' an 'autogen-module' is not on 'other-modules' diff --git a/cabal-testsuite/PackageTests/AutogenModules/Package/setup.out b/cabal-testsuite/PackageTests/AutogenModules/Package/setup.out index d75804e0c8f..dd76b493185 100644 --- a/cabal-testsuite/PackageTests/AutogenModules/Package/setup.out +++ b/cabal-testsuite/PackageTests/AutogenModules/Package/setup.out @@ -1,7 +1,7 @@ # Setup configure Configuring AutogenModules-0.1... Error: [Cabal-5559] -An 'autogen-module' is neither on 'exposed-modules' or 'other-modules'. +An 'autogen-module' is neither on 'exposed-modules' nor 'other-modules'. On executable 'Exe' an 'autogen-module' is not on 'other-modules' @@ -10,7 +10,7 @@ On test suite 'Test' an 'autogen-module' is not on 'other-modules' On benchmark 'Bench' an 'autogen-module' is not on 'other-modules' # Setup sdist Distribution quality errors: -An 'autogen-module' is neither on 'exposed-modules' or 'other-modules'. +An 'autogen-module' is neither on 'exposed-modules' nor 'other-modules'. On executable 'Exe' an 'autogen-module' is not on 'other-modules' On test suite 'Test' an 'autogen-module' is not on 'other-modules' On benchmark 'Bench' an 'autogen-module' is not on 'other-modules' diff --git a/cabal-testsuite/PackageTests/AutogenModules/Package/setup.test.hs b/cabal-testsuite/PackageTests/AutogenModules/Package/setup.test.hs index 2b52b469e22..12fb9823309 100644 --- a/cabal-testsuite/PackageTests/AutogenModules/Package/setup.test.hs +++ b/cabal-testsuite/PackageTests/AutogenModules/Package/setup.test.hs @@ -8,7 +8,7 @@ main = setupAndCabalTest $ do -- Package check messages. let libAutogenMsg = - "An 'autogen-module' is neither on 'exposed-modules' or " + "An 'autogen-module' is neither on 'exposed-modules' nor " ++ "'other-modules'" let exeAutogenMsg = "On executable 'Exe' an 'autogen-module' is not on " From e29b204537be3f26e081d6916eaaa4c65c671d54 Mon Sep 17 00:00:00 2001 From: SuganyaAK Date: Thu, 10 Aug 2023 12:58:05 -0400 Subject: [PATCH 16/16] Updated "AutogenExposeOther" test case which was dependent on this "nor" change --- Cabal/src/Distribution/PackageDescription/Check.hs | 2 +- .../ConfiguredPackage/Sanity/AutogenExposedOther/cabal.out | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cabal/src/Distribution/PackageDescription/Check.hs b/Cabal/src/Distribution/PackageDescription/Check.hs index 3218ba97e54..2c9806a1ae5 100644 --- a/Cabal/src/Distribution/PackageDescription/Check.hs +++ b/Cabal/src/Distribution/PackageDescription/Check.hs @@ -311,7 +311,7 @@ ppExplanation SignaturesCabal2 = ppExplanation AutogenNotExposed = "An 'autogen-module' is neither on 'exposed-modules' nor 'other-modules'." ppExplanation AutogenIncludesNotIncluded = - "An include in 'autogen-includes' is neither in 'includes' nor " + "An include in 'autogen-includes' is neither in 'includes' or " ++ "'install-includes'." ppExplanation (NoMainIs exe) = "No 'main-is' field found for executable " ++ prettyShow (exeName exe) diff --git a/cabal-testsuite/PackageTests/Check/ConfiguredPackage/Sanity/AutogenExposedOther/cabal.out b/cabal-testsuite/PackageTests/Check/ConfiguredPackage/Sanity/AutogenExposedOther/cabal.out index 1d74420d541..94c22120311 100644 --- a/cabal-testsuite/PackageTests/Check/ConfiguredPackage/Sanity/AutogenExposedOther/cabal.out +++ b/cabal-testsuite/PackageTests/Check/ConfiguredPackage/Sanity/AutogenExposedOther/cabal.out @@ -1,4 +1,4 @@ # cabal check The package will not build sanely due to these errors: -Error: An 'autogen-module' is neither on 'exposed-modules' or 'other-modules'. +Error: An 'autogen-module' is neither on 'exposed-modules' nor 'other-modules'. Error: Hackage would reject this package.