Skip to content

Watch mode reports the Show instance of ConstructPlanFailed, instead of a readable error #5978

Closed
@koterpillar

Description

@koterpillar

General summary/comments (optional)

When using --file-watch, and the build plan cannot be constructed, Stack displays an internal error representation instead of a readable error message.

Steps to reproduce

In an empty directory, create stack.yaml with no dependencies, e.g.

resolver: ghc-9.2.4
packages:
- .

Create a Cabal file referencing an unavailable package, e.g.

cabal-version: 1.12

name:           test
version:        0.1.0.0
synopsis:       Test
description:    Test
author:         Test
maintainer:     [email protected]
build-type:     Simple

executable main
  main-is: Main.hs
  hs-source-dirs:
      .
  build-depends:
      base >=4.7 && <5
    , microlens-platform
  default-language: Haskell2010

Run stack build --file-watch.

Expected

Readable error message, such as in the case of stack build without watch:

Error: [S-4804]
       Stack failed to construct a build plan.
       
       While constructing the build plan, Stack encountered the following errors:
       
       In the dependencies for test-0.1.0.0:
           microlens-platform needed, but the Stack configuration has no specified version (latest matching version is 0.4.3.3)
       needed since test is a build target.

Actual

Only an internal error representation shown:

ConstructPlanFailed [UnknownPackage (PackageName "microlens-platform"),DependencyPlanFailures (Package {packageName = PackageName "test", packageVersion = mkVersion [0,1,0,0], packageLicense = Left NONE, packageFiles = <GetPackageFiles>, packageDeps = fromList [(PackageName "base",DepValue {dvVersionRange = IntersectVersionRanges (OrLaterVersion (mkVersion [4,7])) (EarlierVersion (mkVersion [5])), dvType = AsLibrary}),(PackageName "microlens-platform",DepValue {dvVersionRange = OrLaterVersion (mkVersion [0]), dvType = AsLibrary})], packageUnknownTools = fromList [], packageAllDeps = fromList [PackageName "base",PackageName "microlens-platform"], packageGhcOptions = [], packageCabalConfigOpts = [], packageFlags = fromList [], packageDefaultFlags = fromList [], packageLibraries = NoLibraries, packageInternalLibraries = fromList [], packageTests = fromList [], packageBenchmarks = fromList [], packageExes = fromList ["main"], packageOpts = <GetPackageOpts>, packageHasExposedModules = False, packageBuildType = Simple, packageSetupDeps = Nothing, packageCabalSpec = CabalSpecV1_12}) (fromList [(PackageName "microlens-platform",(OrLaterVersion (mkVersion [0]),Just (mkVersion [0,4,3,3],8ef4c8d5b9e0948489aa0b0b6a90c3d0c52e768e4e1f0e3f87697f6abd5d88fd,2930),NotInBuildPlan))])] "/Users/akotlyarov/xaos/stack-construct-plan/stack.yaml" "/Users/akotlyarov/.stack/" (MonoidMap (fromList [(PackageName "base",(First {getFirst = Nothing},[(PackageIdentifier {pkgName = PackageName "test", pkgVersion = mkVersion [0,1,0,0]},IntersectVersionRanges (OrLaterVersion (mkVersion [4,7])) (EarlierVersion (mkVersion [5])))])),(PackageName "microlens-platform",(First {getFirst = Nothing},[(PackageIdentifier {pkgName = PackageName "test", pkgVersion = mkVersion [0,1,0,0]},OrLaterVersion (mkVersion [0]))]))])) (fromList [PackageName "test"]) (fromList [])
Type help for available commands. Press enter to force a rebuild.

Stack version

stack --version
Version 2.9.3, Git revision 6cf638947a863f49857f9cfbf72a38a48b183e7e x86_64 hpack-0.35.1

Method of installation

  • Official binary, downloaded via haskellstack.org or from Stack's repository

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions