Make “sublibrary” standard terminology in docs
[cabal.git] / Cabal / src / Distribution / Simple / Errors.hs
blobdc3e30ab9b6043eee306415999aeff7c15ffabb9
1 -----------------------------------------------------------------------------
3 -- Module : Distribution.Simple.Errors
4 -- Copyright : Suganya Arun
5 -- License : BSD3
6 -- Maintainer : cabal-devel@haskell.org
7 -- Portability : portable
8 --
9 -- A collection of Exception Types in the Cabal library package
11 module Distribution.Simple.Errors
12 ( CabalException (..)
13 , FailedDependency (..)
14 , exceptionCode
15 , exceptionMessage
16 ) where
18 import Distribution.Compat.Prelude
19 import Distribution.Compiler
20 import Distribution.InstalledPackageInfo
21 import Distribution.ModuleName
22 import Distribution.Package
23 import Distribution.PackageDescription (FlagName, UnqualComponentName)
24 import Distribution.Pretty
25 ( Pretty (pretty)
26 , prettyShow
28 import Distribution.Simple.InstallDirs
29 import Distribution.System (OS)
30 import Distribution.Types.BenchmarkType
31 import Distribution.Types.LibraryName
32 import Distribution.Types.PkgconfigVersion
33 import Distribution.Types.TestType
34 import Distribution.Types.VersionRange.Internal ()
35 import Distribution.Version
36 import Text.PrettyPrint
38 data FailedDependency
39 = DependencyNotExists PackageName
40 | DependencyMissingInternal PackageName LibraryName
41 | DependencyNoVersion Dependency
42 deriving (Show)
44 -- Types representing exceptions thrown by functions in all the modules of Cabal Package
45 data CabalException
46 = NoBenchMarkProgram FilePath
47 | EnableBenchMark
48 | BenchMarkNameDisabled String
49 | NoBenchMark String
50 | NoLibraryFound
51 | CompilerNotInstalled CompilerFlavor
52 | CantFindIncludeFile String
53 | UnsupportedTestSuite String
54 | UnsupportedBenchMark String
55 | NoIncludeFileFound String
56 | NoModuleFound ModuleName [String]
57 | RegMultipleInstancePkg
58 | SuppressingChecksOnFile
59 | NoSupportDirStylePackageDb
60 | OnlySupportSpecificPackageDb
61 | FailedToParseOutputDescribe String PackageId
62 | DumpFailed String String
63 | FailedToParseOutputDump String
64 | ListFailed String
65 | FailedToParseOutputList String
66 | ProgramNotFound String
67 | NoSupportForHoogle
68 | NoSupportForQuickJumpFlag
69 | NoGHCVersionFromHaddock
70 | NoGHCVersionFromCompiler
71 | HaddockAndGHCVersionDoesntMatch Version Version
72 | MustHaveSharedLibraries
73 | HaddockPackageFlags [(InstalledPackageInfo, [UnitId])]
74 | UnknownCompilerFlavor CompilerFlavor
75 | FailedToDetermineTarget
76 | NoMultipleTargets
77 | REPLNotSupported
78 | NoSupportBuildingTestSuite TestType
79 | NoSupportBuildingBenchMark BenchmarkType
80 | BuildingNotSupportedWithCompiler
81 | ProvideHaskellSuiteTool String
82 | CannotDetermineCompilerVersion
83 | PkgDumpFailed
84 | FailedToParseOutput
85 | CantFindSourceModule ModuleName
86 | VersionMismatchJS FilePath Version FilePath Version
87 | VersionMismatchGHCJS FilePath Version FilePath Version
88 | GlobalPackageDBLimitation
89 | GlobalPackageDBSpecifiedFirst
90 | MatchDirFileGlob String
91 | MatchDirFileGlobErrors [String]
92 | ErrorParsingFileDoesntExist FilePath
93 | FailedParsing String
94 | NotFoundMsg
95 | UnrecognisedBuildTarget [String]
96 | ReportBuildTargetProblems [(String, [String], String)]
97 | UnknownBuildTarget [(String, [(String, String)])]
98 | AmbiguousBuildTarget [(String, [(String, String)])]
99 | CheckBuildTargets String
100 | VersionMismatchGHC FilePath Version FilePath Version
101 | CheckPackageDbStackPost76
102 | CheckPackageDbStackPre76
103 | GlobalPackageDbSpecifiedFirst
104 | CantInstallForeignLib
105 | NoSupportForPreProcessingTest TestType
106 | NoSupportForPreProcessingBenchmark BenchmarkType
107 | CantFindSourceForPreProcessFile String
108 | NoSupportPreProcessingTestExtras TestType
109 | NoSupportPreProcessingBenchmarkExtras BenchmarkType
110 | UnlitException String
111 | RunProgramInvocationException FilePath String
112 | GetProgramInvocationException FilePath String
113 | GetProgramInvocationLBSException FilePath String
114 | CheckSemaphoreSupport
115 | NoLibraryForPackage
116 | SanityCheckHookedBuildInfo UnqualComponentName
117 | ConfigureScriptNotFound
118 | NoValidComponent
119 | ConfigureEitherSingleOrAll
120 | ConfigCIDValidForPreComponent
121 | SanityCheckForEnableComponents
122 | SanityCheckForDynamicStaticLinking
123 | UnsupportedLanguages PackageIdentifier CompilerId [String]
124 | UnsupportedLanguageExtension PackageIdentifier CompilerId [String]
125 | CantFindForeignLibraries [String]
126 | ExpectedAbsoluteDirectory FilePath
127 | FlagsNotSpecified [FlagName]
128 | EncounteredMissingDependency [Dependency]
129 | CompilerDoesn'tSupportThinning
130 | CompilerDoesn'tSupportReexports
131 | CompilerDoesn'tSupportBackpack
132 | LibraryWithinSamePackage [PackageId]
133 | ReportFailedDependencies [FailedDependency] String
134 | NoPackageDatabaseSpecified
135 | HowToFindInstalledPackages CompilerFlavor
136 | PkgConfigNotFound String String
137 | BadVersion String String PkgconfigVersion
138 | UnknownCompilerException
139 | NoWorkingGcc
140 | NoOSSupport OS
141 | NoCompilerSupport String
142 | InstallDirsNotPrefixRelative (InstallDirs FilePath)
143 | ExplainErrors (Maybe (Either [Char] [Char])) [String]
144 | CheckPackageProblems [String]
145 | LibDirDepsPrefixNotRelative FilePath FilePath
146 | CombinedConstraints Doc
147 | CantParseGHCOutput
148 | IncompatibleWithCabal String String
149 | Couldn'tFindTestProgram FilePath
150 | TestCoverageSupport
151 | Couldn'tFindTestProgLibV09 FilePath
152 | TestCoverageSupportLibV09
153 | RawSystemStdout String
154 | FindFileCwd FilePath
155 | FindFileEx FilePath
156 | FindModuleFileEx ModuleName [String] [FilePath]
157 | MultipleFilesWithExtension String
158 | NoDesc
159 | MultiDesc [String]
160 | RelocRegistrationInfo
161 | CreatePackageDB
162 | WithHcPkg String
163 | RegisMultiplePkgNotSupported
164 | RegisteringNotImplemented
165 | NoTestSuitesEnabled
166 | TestNameDisabled String
167 | NoSuchTest String
168 | ConfigureProgram String FilePath
169 | RequireProgram String
170 | NoProgramFound String VersionRange
171 | BadVersionDb String Version VersionRange FilePath
172 | UnknownVersionDb String VersionRange FilePath
173 deriving (Show, Typeable)
175 exceptionCode :: CabalException -> Int
176 exceptionCode e = case e of
177 NoBenchMarkProgram{} -> 1678
178 EnableBenchMark{} -> 1453
179 BenchMarkNameDisabled{} -> 2781
180 NoBenchMark{} -> 1654
181 NoLibraryFound -> 2546
182 CompilerNotInstalled{} -> 7465
183 CantFindIncludeFile{} -> 3876
184 UnsupportedTestSuite{} -> 3245
185 UnsupportedBenchMark{} -> 9123
186 NoIncludeFileFound{} -> 2987
187 NoModuleFound{} -> 6421
188 RegMultipleInstancePkg{} -> 3421
189 SuppressingChecksOnFile{} -> 5436
190 NoSupportDirStylePackageDb -> 2980
191 OnlySupportSpecificPackageDb -> 6547
192 FailedToParseOutputDescribe{} -> 7218
193 DumpFailed{} -> 6736
194 FailedToParseOutputDump{} -> 9076
195 ListFailed{} -> 5109
196 FailedToParseOutputList{} -> 7650
197 ProgramNotFound{} -> 4123
198 NoSupportForHoogle{} -> 8706
199 NoSupportForQuickJumpFlag{} -> 7086
200 NoGHCVersionFromHaddock -> 5045
201 NoGHCVersionFromCompiler -> 4098
202 HaddockAndGHCVersionDoesntMatch{} -> 1998
203 MustHaveSharedLibraries{} -> 6032
204 HaddockPackageFlags{} -> 4569
205 UnknownCompilerFlavor{} -> 3102
206 FailedToDetermineTarget{} -> 5049
207 NoMultipleTargets{} -> 6091
208 REPLNotSupported{} -> 1098
209 NoSupportBuildingTestSuite{} -> 4106
210 NoSupportBuildingBenchMark{} -> 5320
211 BuildingNotSupportedWithCompiler{} -> 7077
212 ProvideHaskellSuiteTool{} -> 7509
213 CannotDetermineCompilerVersion{} -> 4519
214 PkgDumpFailed{} -> 2291
215 FailedToParseOutput{} -> 5500
216 CantFindSourceModule{} -> 8870
217 VersionMismatchJS{} -> 9001
218 VersionMismatchGHCJS{} -> 4001
219 GlobalPackageDBLimitation{} -> 5002
220 GlobalPackageDBSpecifiedFirst{} -> 3901
221 MatchDirFileGlob{} -> 9760
222 MatchDirFileGlobErrors{} -> 6661
223 ErrorParsingFileDoesntExist{} -> 1234
224 FailedParsing{} -> 6565
225 NotFoundMsg{} -> 8011
226 UnrecognisedBuildTarget{} -> 3410
227 ReportBuildTargetProblems{} -> 5504
228 UnknownBuildTarget{} -> 4444
229 AmbiguousBuildTarget{} -> 7865
230 CheckBuildTargets{} -> 4733
231 VersionMismatchGHC{} -> 4000
232 CheckPackageDbStackPost76{} -> 3000
233 CheckPackageDbStackPre76{} -> 5640
234 GlobalPackageDbSpecifiedFirst{} -> 2345
235 CantInstallForeignLib{} -> 8221
236 NoSupportForPreProcessingTest{} -> 3008
237 NoSupportForPreProcessingBenchmark{} -> 6990
238 CantFindSourceForPreProcessFile{} -> 7554
239 NoSupportPreProcessingTestExtras{} -> 7886
240 NoSupportPreProcessingBenchmarkExtras{} -> 9999
241 UnlitException{} -> 5454
242 RunProgramInvocationException{} -> 8012
243 GetProgramInvocationException{} -> 7300
244 GetProgramInvocationLBSException{} -> 6578
245 CheckSemaphoreSupport{} -> 2002
246 NoLibraryForPackage{} -> 8004
247 SanityCheckHookedBuildInfo{} -> 6007
248 ConfigureScriptNotFound{} -> 4567
249 NoValidComponent{} -> 5680
250 ConfigureEitherSingleOrAll{} -> 2001
251 ConfigCIDValidForPreComponent{} -> 7006
252 SanityCheckForEnableComponents{} -> 5004
253 SanityCheckForDynamicStaticLinking{} -> 4007
254 UnsupportedLanguages{} -> 8074
255 UnsupportedLanguageExtension{} -> 5656
256 CantFindForeignLibraries{} -> 4574
257 ExpectedAbsoluteDirectory{} -> 6662
258 FlagsNotSpecified{} -> 9080
259 EncounteredMissingDependency{} -> 8010
260 CompilerDoesn'tSupportThinning{} -> 4003
261 CompilerDoesn'tSupportReexports{} -> 3456
262 CompilerDoesn'tSupportBackpack{} -> 5446
263 LibraryWithinSamePackage{} -> 7007
264 ReportFailedDependencies{} -> 4321
265 NoPackageDatabaseSpecified{} -> 2300
266 HowToFindInstalledPackages{} -> 3003
267 PkgConfigNotFound{} -> 7123
268 BadVersion{} -> 7600
269 UnknownCompilerException{} -> 3022
270 NoWorkingGcc{} -> 1088
271 NoOSSupport{} -> 3339
272 NoCompilerSupport{} -> 2290
273 InstallDirsNotPrefixRelative{} -> 6000
274 ExplainErrors{} -> 4345
275 CheckPackageProblems{} -> 5559
276 LibDirDepsPrefixNotRelative{} -> 6667
277 CombinedConstraints{} -> 5000
278 CantParseGHCOutput{} -> 1980
279 IncompatibleWithCabal{} -> 8123
280 Couldn'tFindTestProgram{} -> 5678
281 TestCoverageSupport{} -> 7890
282 Couldn'tFindTestProgLibV09{} -> 9012
283 TestCoverageSupportLibV09{} -> 1076
284 RawSystemStdout{} -> 3098
285 FindFileCwd{} -> 4765
286 FindFileEx{} -> 2115
287 FindModuleFileEx{} -> 6663
288 MultipleFilesWithExtension{} -> 3333
289 NoDesc{} -> 7654
290 MultiDesc{} -> 5554
291 RelocRegistrationInfo{} -> 4343
292 CreatePackageDB{} -> 6787
293 WithHcPkg{} -> 9876
294 RegisMultiplePkgNotSupported{} -> 7632
295 RegisteringNotImplemented{} -> 5411
296 NoTestSuitesEnabled{} -> 9061
297 TestNameDisabled{} -> 8210
298 NoSuchTest{} -> 8000
299 ConfigureProgram{} -> 5490
300 RequireProgram{} -> 6666
301 NoProgramFound{} -> 7620
302 BadVersionDb{} -> 8038
303 UnknownVersionDb{} -> 1008
305 versionRequirement :: VersionRange -> String
306 versionRequirement range
307 | isAnyVersion range = ""
308 | otherwise = " version " ++ prettyShow range
310 exceptionMessage :: CabalException -> String
311 exceptionMessage e = case e of
312 NoBenchMarkProgram cmd -> "Could not find benchmark program \"" ++ cmd ++ "\". Did you build the package first?"
313 EnableBenchMark -> "No benchmarks enabled. Did you remember to configure with " ++ "\'--enable-benchmarks\'?"
314 BenchMarkNameDisabled bmName -> "Package configured with benchmark " ++ bmName ++ " disabled."
315 NoBenchMark bmName -> "no such benchmark: " ++ bmName
316 NoLibraryFound -> "No executables and no library found. Nothing to do."
317 CompilerNotInstalled compilerFlavor -> "installing with " ++ prettyShow compilerFlavor ++ "is not implemented"
318 CantFindIncludeFile file -> "can't find include file " ++ file
319 UnsupportedTestSuite testType -> "Unsupported test suite type: " ++ testType
320 UnsupportedBenchMark benchMarkType -> "Unsupported benchmark type: " ++ benchMarkType
321 NoIncludeFileFound f -> "can't find include file " ++ f
322 NoModuleFound m suffixes ->
323 "Could not find module: "
324 ++ prettyShow m
325 ++ " with any suffix: "
326 ++ show suffixes
327 ++ ".\n"
328 ++ "If the module "
329 ++ "is autogenerated it should be added to 'autogen-modules'."
330 RegMultipleInstancePkg -> "HcPkg.register: the compiler does not support,registering multiple instances of packages."
331 SuppressingChecksOnFile -> "HcPkg.register: the compiler does not support ,suppressing checks on files."
332 NoSupportDirStylePackageDb -> "HcPkg.writeRegistrationFileDirectly: compiler does not support dir style package dbs"
333 OnlySupportSpecificPackageDb -> "HcPkg.writeRegistrationFileDirectly: only supports SpecificPackageDB for now"
334 FailedToParseOutputDescribe programId pkgId -> "failed to parse output of '" ++ programId ++ " describe " ++ prettyShow pkgId ++ "'"
335 DumpFailed programId exception -> programId ++ " dump failed: " ++ exception
336 FailedToParseOutputDump programId -> "failed to parse output of '" ++ programId ++ " dump'"
337 ListFailed programId -> programId ++ " list failed"
338 FailedToParseOutputList programId -> "failed to parse output of '" ++ programId ++ " list'"
339 ProgramNotFound progName -> "The program '" ++ progName ++ "' is required but it could not be found"
340 NoSupportForHoogle -> "Haddock 2.0 and 2.1 do not support the --hoogle flag."
341 NoSupportForQuickJumpFlag -> "Haddock prior to 2.19 does not support the --quickjump flag."
342 NoGHCVersionFromHaddock -> "Could not get GHC version from Haddock"
343 NoGHCVersionFromCompiler -> "Could not get GHC version from compiler"
344 HaddockAndGHCVersionDoesntMatch ghcVersion haddockGhcVersion ->
345 "Haddock's internal GHC version must match the configured "
346 ++ "GHC version.\n"
347 ++ "The GHC version is "
348 ++ prettyShow ghcVersion
349 ++ " but "
350 ++ "haddock is using GHC version "
351 ++ prettyShow haddockGhcVersion
352 MustHaveSharedLibraries -> "Must have vanilla or shared libraries " ++ "enabled in order to run haddock"
353 HaddockPackageFlags inf ->
354 "internal error when calculating transitive "
355 ++ "package dependencies.\nDebug info: "
356 ++ show inf
357 UnknownCompilerFlavor compilerFlavor -> "dumpBuildInfo: Unknown compiler flavor: " ++ show compilerFlavor
358 FailedToDetermineTarget -> "Failed to determine target."
359 NoMultipleTargets -> "The 'repl' command does not support multiple targets at once."
360 REPLNotSupported -> "A REPL is not supported with this compiler."
361 NoSupportBuildingTestSuite testType -> "No support for building test suite type " ++ show testType
362 NoSupportBuildingBenchMark benchMarkType -> "No support for building benchmark type " ++ show benchMarkType
363 BuildingNotSupportedWithCompiler -> "Building is not supported with this compiler."
364 ProvideHaskellSuiteTool msg -> show msg
365 CannotDetermineCompilerVersion -> "haskell-suite: couldn't determine compiler version"
366 PkgDumpFailed -> "pkg dump failed"
367 FailedToParseOutput -> "failed to parse output of 'pkg dump'"
368 CantFindSourceModule moduleName -> "can't find source for module " ++ prettyShow moduleName
369 VersionMismatchJS ghcjsProgPath ghcjsVersion ghcjsPkgProgPath ghcjsPkgGhcjsVersion ->
370 "Version mismatch between ghcjs and ghcjs-pkg: "
371 ++ show ghcjsProgPath
372 ++ " is version "
373 ++ prettyShow ghcjsVersion
374 ++ " "
375 ++ show ghcjsPkgProgPath
376 ++ " is version "
377 ++ prettyShow ghcjsPkgGhcjsVersion
378 VersionMismatchGHCJS ghcjsProgPath ghcjsGhcVersion ghcjsPkgProgPath ghcjsPkgVersion ->
379 "Version mismatch between ghcjs and ghcjs-pkg: "
380 ++ show ghcjsProgPath
381 ++ " was built with GHC version "
382 ++ prettyShow ghcjsGhcVersion
383 ++ " "
384 ++ show ghcjsPkgProgPath
385 ++ " was built with GHC version "
386 ++ prettyShow ghcjsPkgVersion
387 GlobalPackageDBLimitation ->
388 "With current ghc versions the global package db is always used "
389 ++ "and must be listed first. This ghc limitation may be lifted in "
390 ++ "future, see https://gitlab.haskell.org/ghc/ghc/-/issues/5977"
391 GlobalPackageDBSpecifiedFirst ->
392 "If the global package db is specified, it must be "
393 ++ "specified first and cannot be specified multiple times"
394 MatchDirFileGlob pathError -> pathError
395 MatchDirFileGlobErrors errors -> unlines errors
396 ErrorParsingFileDoesntExist filePath -> "Error Parsing: file \"" ++ filePath ++ "\" doesn't exist. Cannot continue."
397 FailedParsing name -> "Failed parsing \"" ++ name ++ "\"."
398 NotFoundMsg ->
399 "The package has a './configure' script. "
400 ++ "If you are on Windows, This requires a "
401 ++ "Unix compatibility toolchain such as MinGW+MSYS or Cygwin. "
402 ++ "If you are not on Windows, ensure that an 'sh' command "
403 ++ "is discoverable in your path."
404 UnrecognisedBuildTarget target ->
405 unlines
406 [ "Unrecognised build target '" ++ name ++ "'."
407 | name <- target
409 ++ "Examples:\n"
410 ++ " - build foo -- component name "
411 ++ "(library, executable, test-suite or benchmark)\n"
412 ++ " - build Data.Foo -- module name\n"
413 ++ " - build Data/Foo.hsc -- file name\n"
414 ++ " - build lib:foo exe:foo -- component qualified by kind\n"
415 ++ " - build foo:Data.Foo -- module qualified by component\n"
416 ++ " - build foo:Data/Foo.hsc -- file qualified by component"
417 ReportBuildTargetProblems targets ->
418 unlines
419 [ "Unrecognised build target '"
420 ++ target
421 ++ "'.\n"
422 ++ "Expected a "
423 ++ intercalate " or " expected
424 ++ ", rather than '"
425 ++ got
426 ++ "'."
427 | (target, expected, got) <- targets
429 UnknownBuildTarget targets ->
430 unlines
431 [ "Unknown build target '"
432 ++ target
433 ++ "'.\nThere is no "
434 ++ intercalate
435 " or "
436 [ mungeThing thing ++ " '" ++ got ++ "'"
437 | (thing, got) <- nosuch
439 ++ "."
440 | (target, nosuch) <- targets
442 where
443 mungeThing "file" = "file target"
444 mungeThing thing = thing
445 AmbiguousBuildTarget targets ->
446 unlines
447 [ "Ambiguous build target '"
448 ++ target
449 ++ "'. It could be:\n "
450 ++ unlines
451 [ " "
452 ++ ut
453 ++ " ("
454 ++ bt
455 ++ ")"
456 | (ut, bt) <- amb
458 | (target, amb) <- targets
460 CheckBuildTargets errorStr -> errorStr
461 VersionMismatchGHC ghcProgPath ghcVersion ghcPkgProgPath ghcPkgVersion ->
462 "Version mismatch between ghc and ghc-pkg: "
463 ++ ghcProgPath
464 ++ " is version "
465 ++ prettyShow ghcVersion
466 ++ " "
467 ++ ghcPkgProgPath
468 ++ " is version "
469 ++ prettyShow ghcPkgVersion
470 CheckPackageDbStackPost76 ->
471 "If the global package db is specified, it must be "
472 ++ "specified first and cannot be specified multiple times"
473 CheckPackageDbStackPre76 ->
474 "With current ghc versions the global package db is always used "
475 ++ "and must be listed first. This ghc limitation is lifted in GHC 7.6,"
476 ++ "see https://gitlab.haskell.org/ghc/ghc/-/issues/5977"
477 GlobalPackageDbSpecifiedFirst ->
478 "If the global package db is specified, it must be "
479 ++ "specified first and cannot be specified multiple times"
480 CantInstallForeignLib -> "Can't install foreign-library symlink on non-Linux OS"
481 NoSupportForPreProcessingTest tt ->
482 "No support for preprocessing test "
483 ++ "suite type "
484 ++ prettyShow tt
485 NoSupportForPreProcessingBenchmark tt ->
486 "No support for preprocessing benchmark "
487 ++ "type "
488 ++ prettyShow tt
489 CantFindSourceForPreProcessFile errorStr -> errorStr
490 NoSupportPreProcessingTestExtras tt ->
491 "No support for preprocessing test suite type "
492 ++ prettyShow tt
493 NoSupportPreProcessingBenchmarkExtras tt ->
494 "No support for preprocessing benchmark "
495 ++ "type "
496 ++ prettyShow tt
497 UnlitException str -> str
498 RunProgramInvocationException path errors -> "'" ++ path ++ "' exited with an error:\n" ++ errors
499 GetProgramInvocationException path errors -> "'" ++ path ++ "' exited with an error:\n" ++ errors
500 GetProgramInvocationLBSException path errors -> "'" ++ path ++ "' exited with an error:\n" ++ errors
501 CheckSemaphoreSupport ->
502 "Your compiler does not support the -jsem flag. "
503 ++ "To use this feature you must use GHC 9.8 or later."
504 NoLibraryForPackage ->
505 "The buildinfo contains info for a library, "
506 ++ "but the package does not have a library."
507 SanityCheckHookedBuildInfo exe1 ->
508 "The buildinfo contains info for an executable called '"
509 ++ prettyShow exe1
510 ++ "' but the package does not have a "
511 ++ "executable with that name."
512 ConfigureScriptNotFound -> "configure script not found."
513 NoValidComponent -> "No valid component targets found"
514 ConfigureEitherSingleOrAll -> "Can only configure either single component or all of them"
515 ConfigCIDValidForPreComponent -> "--cid is only supported for per-component configure"
516 SanityCheckForEnableComponents ->
517 "--enable-tests/--enable-benchmarks are incompatible with"
518 ++ " explicitly specifying a component to configure."
519 SanityCheckForDynamicStaticLinking ->
520 "--enable-executable-dynamic and --enable-executable-static"
521 ++ " are incompatible with each other."
522 UnsupportedLanguages pkgId compilerId langs ->
523 "The package "
524 ++ prettyShow (pkgId)
525 ++ " requires the following languages which are not "
526 ++ "supported by "
527 ++ prettyShow (compilerId)
528 ++ ": "
529 ++ intercalate ", " langs
530 UnsupportedLanguageExtension pkgId compilerId exts ->
531 "The package "
532 ++ prettyShow (pkgId)
533 ++ " requires the following language extensions which are not "
534 ++ "supported by "
535 ++ prettyShow (compilerId)
536 ++ ": "
537 ++ intercalate ", " exts
538 CantFindForeignLibraries unsupportedFLibs ->
539 "Cannot build some foreign libraries: "
540 ++ intercalate "," unsupportedFLibs
541 ExpectedAbsoluteDirectory fPath -> "expected an absolute directory name for --prefix: " ++ fPath
542 FlagsNotSpecified diffFlags ->
543 "'--exact-configuration' was given, "
544 ++ "but the following flags were not specified: "
545 ++ intercalate ", " (map show diffFlags)
546 EncounteredMissingDependency missing ->
547 "Encountered missing or private dependencies:\n"
548 ++ ( render
549 . nest 4
550 . sep
551 . punctuate comma
552 . map (pretty . simplifyDependency)
553 $ missing
555 CompilerDoesn'tSupportThinning ->
556 "Your compiler does not support thinning and renaming on "
557 ++ "package flags. To use this feature you must use "
558 ++ "GHC 7.9 or later."
559 CompilerDoesn'tSupportReexports ->
560 "Your compiler does not support module re-exports. To use "
561 ++ "this feature you must use GHC 7.9 or later."
562 CompilerDoesn'tSupportBackpack ->
563 "Your compiler does not support Backpack. To use "
564 ++ "this feature you must use GHC 8.1 or later."
565 LibraryWithinSamePackage internalPkgDeps ->
566 "The field 'build-depends: "
567 ++ intercalate ", " (map (prettyShow . packageName) internalPkgDeps)
568 ++ "' refers to a library which is defined within the same "
569 ++ "package. To use this feature the package must specify at "
570 ++ "least 'cabal-version: >= 1.8'."
571 ReportFailedDependencies failed hackageUrl -> (intercalate "\n\n" (map reportFailedDependency failed))
572 where
573 reportFailedDependency (DependencyNotExists pkgname) =
574 "there is no version of "
575 ++ prettyShow pkgname
576 ++ " installed.\n"
577 ++ "Perhaps you need to download and install it from\n"
578 ++ hackageUrl
579 ++ prettyShow pkgname
580 ++ "?"
581 reportFailedDependency (DependencyMissingInternal pkgname lib) =
582 "internal dependency "
583 ++ prettyShow (prettyLibraryNameComponent lib)
584 ++ " not installed.\n"
585 ++ "Perhaps you need to configure and install it first?\n"
586 ++ "(This library was defined by "
587 ++ prettyShow pkgname
588 ++ ")"
589 reportFailedDependency (DependencyNoVersion dep) =
590 "cannot satisfy dependency " ++ prettyShow (simplifyDependency dep) ++ "\n"
591 NoPackageDatabaseSpecified ->
592 "No package databases have been specified. If you use "
593 ++ "--package-db=clear, you must follow it with --package-db= "
594 ++ "with 'global', 'user' or a specific file."
595 HowToFindInstalledPackages flv ->
596 "don't know how to find the installed packages for "
597 ++ prettyShow flv
598 PkgConfigNotFound pkg versionReq ->
599 "The pkg-config package '"
600 ++ pkg
601 ++ "'"
602 ++ versionReq
603 ++ " is required but it could not be found."
604 BadVersion pkg versionReq v ->
605 "The pkg-config package '"
606 ++ pkg
607 ++ "'"
608 ++ versionReq
609 ++ " is required but the version installed on the"
610 ++ " system is version "
611 ++ prettyShow v
612 UnknownCompilerException -> "Unknown compiler"
613 NoWorkingGcc ->
614 unlines
615 [ "No working gcc"
616 , "This package depends on foreign library but we cannot "
617 ++ "find a working C compiler. If you have it in a "
618 ++ "non-standard location you can use the --with-gcc "
619 ++ "flag to specify it."
621 NoOSSupport os ->
622 "Operating system: "
623 ++ prettyShow os
624 ++ ", does not support relocatable builds"
625 NoCompilerSupport comp ->
626 "Compiler: "
627 ++ comp
628 ++ ", does not support relocatable builds"
629 InstallDirsNotPrefixRelative installDirs -> "Installation directories are not prefix_relative:\n" ++ show installDirs
630 ExplainErrors hdr libs ->
631 unlines $
632 [ if plural
633 then "Missing dependencies on foreign libraries:"
634 else "Missing dependency on a foreign library:"
635 | missing
637 ++ case hdr of
638 Just (Left h) -> ["* Missing (or bad) header file: " ++ h]
639 _ -> []
640 ++ case libs of
641 [] -> []
642 [lib] -> ["* Missing (or bad) C library: " ++ lib]
643 _ ->
644 [ "* Missing (or bad) C libraries: "
645 ++ intercalate ", " libs
647 ++ [if plural then messagePlural else messageSingular | missing]
648 ++ case hdr of
649 Just (Left _) -> [headerCppMessage]
650 Just (Right h) ->
651 [ (if missing then "* " else "")
652 ++ "Bad header file: "
653 ++ h
654 , headerCcMessage
656 _ -> []
657 where
658 plural = length libs >= 2
659 -- Is there something missing? (as opposed to broken)
660 missing =
661 not (null libs)
662 || case hdr of Just (Left _) -> True; _ -> False
663 messageSingular =
664 "This problem can usually be solved by installing the system "
665 ++ "package that provides this library (you may need the "
666 ++ "\"-dev\" version). If the library is already installed "
667 ++ "but in a non-standard location then you can use the flags "
668 ++ "--extra-include-dirs= and --extra-lib-dirs= to specify "
669 ++ "where it is."
670 ++ "If the library file does exist, it may contain errors that "
671 ++ "are caught by the C compiler at the preprocessing stage. "
672 ++ "In this case you can re-run configure with the verbosity "
673 ++ "flag -v3 to see the error messages."
674 messagePlural =
675 "This problem can usually be solved by installing the system "
676 ++ "packages that provide these libraries (you may need the "
677 ++ "\"-dev\" versions). If the libraries are already installed "
678 ++ "but in a non-standard location then you can use the flags "
679 ++ "--extra-include-dirs= and --extra-lib-dirs= to specify "
680 ++ "where they are."
681 ++ "If the library files do exist, it may contain errors that "
682 ++ "are caught by the C compiler at the preprocessing stage. "
683 ++ "In this case you can re-run configure with the verbosity "
684 ++ "flag -v3 to see the error messages."
685 headerCppMessage =
686 "If the header file does exist, it may contain errors that "
687 ++ "are caught by the C compiler at the preprocessing stage. "
688 ++ "In this case you can re-run configure with the verbosity "
689 ++ "flag -v3 to see the error messages."
690 headerCcMessage =
691 "The header file contains a compile error. "
692 ++ "You can re-run configure with the verbosity flag "
693 ++ "-v3 to see the error messages from the C compiler."
694 CheckPackageProblems errors -> (intercalate "\n\n" $ errors)
695 LibDirDepsPrefixNotRelative l p ->
696 "Library directory of a dependency: "
697 ++ show l
698 ++ "\nis not relative to the installation prefix:\n"
699 ++ show p
700 CombinedConstraints dispDepend ->
701 render $
702 text "The following package dependencies were requested"
703 $+$ nest 4 dispDepend
704 $+$ text "however the given installed package instance does not exist."
705 CantParseGHCOutput -> "Can't parse --info output of GHC"
706 IncompatibleWithCabal compilerName packagePathEnvVar ->
707 "Use of "
708 ++ compilerName
709 ++ "'s environment variable "
710 ++ packagePathEnvVar
711 ++ " is incompatible with Cabal. Use the "
712 ++ "flag --package-db to specify a package database (it can be "
713 ++ "used multiple times)."
714 Couldn'tFindTestProgram cmd ->
715 "Could not find test program \""
716 ++ cmd
717 ++ "\". Did you build the package first?"
718 TestCoverageSupport -> "Test coverage is only supported for packages with a library component."
719 Couldn'tFindTestProgLibV09 cmd ->
720 "Could not find test program \""
721 ++ cmd
722 ++ "\". Did you build the package first?"
723 TestCoverageSupportLibV09 -> "Test coverage is only supported for packages with a library component."
724 RawSystemStdout errors -> errors
725 FindFileCwd fileName -> fileName ++ " doesn't exist"
726 FindFileEx fileName -> fileName ++ " doesn't exist"
727 FindModuleFileEx mod_name extensions searchPath ->
728 "Could not find module: "
729 ++ prettyShow mod_name
730 ++ " with any suffix: "
731 ++ show extensions
732 ++ " in the search path: "
733 ++ show searchPath
734 MultipleFilesWithExtension buildInfoExt -> "Multiple files with extension " ++ buildInfoExt
735 NoDesc ->
736 "No cabal file found.\n"
737 ++ "Please create a package description file <pkgname>.cabal"
738 MultiDesc l ->
739 "Multiple cabal files found.\n"
740 ++ "Please use only one of: "
741 ++ intercalate ", " l
742 RelocRegistrationInfo ->
743 "Distribution.Simple.Register.relocRegistrationInfo: \
744 \not implemented for this compiler"
745 CreatePackageDB ->
746 "Distribution.Simple.Register.createPackageDB: "
747 ++ "not implemented for this compiler"
748 WithHcPkg name ->
749 "Distribution.Simple.Register."
750 ++ name
751 ++ ":\
752 \not implemented for this compiler"
753 RegisMultiplePkgNotSupported -> "Registering multiple package instances is not yet supported for this compiler"
754 RegisteringNotImplemented -> "Registering is not implemented for this compiler"
755 NoTestSuitesEnabled ->
756 "No test suites enabled. Did you remember to configure with "
757 ++ "\'--enable-tests\'?"
758 TestNameDisabled tName ->
759 "Package configured with test suite "
760 ++ tName
761 ++ " disabled."
762 NoSuchTest tName -> "no such test: " ++ tName
763 ConfigureProgram name path ->
764 "Cannot find the program '"
765 ++ name
766 ++ "'. User-specified path '"
767 ++ path
768 ++ "' does not refer to an executable and "
769 ++ "the program is not on the system path."
770 RequireProgram progName -> "The program '" ++ progName ++ "' is required but it could not be found."
771 NoProgramFound progName versionRange ->
772 "The program '"
773 ++ progName
774 ++ "'"
775 ++ versionRequirement versionRange
776 ++ " is required but it could not be found."
777 BadVersionDb progName version range locationPath ->
778 "The program '"
779 ++ progName
780 ++ "'"
781 ++ versionRequirement range
782 ++ " is required but the version found at "
783 ++ locationPath
784 ++ " is version "
785 ++ prettyShow version
786 UnknownVersionDb progName versionRange locationPath ->
787 "The program '"
788 ++ progName
789 ++ "'"
790 ++ versionRequirement versionRange
791 ++ " is required but the version of "
792 ++ locationPath
793 ++ " could not be determined."