commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
4k stars 843 forks source link

Stack --file-watch prints show'n exception, not understandable error message #6055

Closed pbrisbin closed 1 year ago

pbrisbin commented 1 year ago

General summary/comments (optional)

I've noticed stack emitting a mess of unreadable shown exception data instead of a pretty error message in some cases. I was able to catch at least one instance just now, and realized it only happens with --file-watch.

Steps to reproduce

Example project:

stack.yaml and package.yaml ```yaml resolver: lts-20.10 extra-deps: - github: brendanhay/amazonka commit: f73a957d05f64863e867cf39d0db260718f0fadd # main, as of SSO support subdirs: - lib/amazonka - lib/amazonka-core - lib/services/amazonka-autoscaling - lib/services/amazonka-sqs - lib/services/amazonka-sso - lib/services/amazonka-sts ``` ```yaml name: agent version: 0.0.0.1 license: MIT dependencies: - base library: source-dirs: src dependencies: - Blammo - aeson - amazonka - amazonka-autoscaling - amazonka-sqs - bytestring - composition-extra - conduit - conduit-extra - data-default-class - envparse - errors - github - hedis - http-conduit - http-types - immortal - jwt - microlens-platform - monad-logger - monad-validate - optparse-applicative - relude - resourcet - tagged - text - time - tls - typed-process - unliftio - unliftio-core ```

Expected

This is what you get without --file-watch,

% stack build --fast --pedantic --test

Error: [S-4804]
       Stack failed to construct a build plan.

       While constructing the build plan, Stack encountered the following errors:

       In the dependencies for agent-0.0.0.1:
           monad-validate needed, but the Stack configuration has no specified version (latest
                          matching version is 1.2.0.1)
       needed since agent is a build target.

I should see the same.

Actual

This is what I see with --file-watch

% stack build --fast --pedantic --test --file-watch
ConstructPlanFailed [DependencyPlanFailures (Package {packageName = PackageName
"agent", packageVersion = mkVersion [0,0,0,1], packageLicense = Right MIT,
packageFiles = <GetPackageFiles>, packageDeps = fromList [(PackageName
"Blammo",DepValue {dvVersionRange = OrLaterVersion (mkVersion [0]), dvType =
AsLibrary}),(PackageName "aeson",DepValue {dvVersionRange = OrLaterVersion
(mkVersion [0]), dvType = AsLibrary}),(PackageName "amazonka",DepValue
{dvVersionRange = OrLaterVersion (mkVersion [0]), dvType =
AsLibrary}),(PackageName "amazonka-autoscaling",DepValue {dvVersionRange =
OrLaterVersion (mkVersion [0]), dvType = AsLibrary}),(PackageName
"amazonka-sqs",DepValue {dvVersionRange = OrLaterVersion (mkVersion [0]), dvType
= AsLibrary}),(PackageName "base",DepValue {dvVersionRange = OrLaterVersion
(mkVersion [0]), dvType = AsLibrary}),(PackageName "bytestring",DepValue
{dvVersionRange = OrLaterVersion (mkVersion [0]), dvType =
AsLibrary}),(PackageName "composition-extra",DepValue {dvVersionRange =
OrLaterVersion (mkVersion [0]), dvType = AsLibrary}),(PackageName
"conduit",DepValue {dvVersionRange = OrLaterVersion (mkVersion [0]), dvType =
AsLibrary}),(PackageName "conduit-extra",DepValue {dvVersionRange =
OrLaterVersion (mkVersion [0]), dvType = AsLibrary}),(PackageName
"data-default-class",DepValue {dvVersionRange = OrLaterVersion (mkVersion [0]),
dvType = AsLibrary}),(PackageName "envparse",DepValue {dvVersionRange =
OrLaterVersion (mkVersion [0]), dvType = AsLibrary}),(PackageName
"errors",DepValue {dvVersionRange = OrLaterVersion (mkVersion [0]), dvType =
AsLibrary}),(PackageName "github",DepValue {dvVersionRange = OrLaterVersion
(mkVersion [0]), dvType = AsLibrary}),(PackageName "hedis",DepValue
{dvVersionRange = OrLaterVersion (mkVersion [0]), dvType =
AsLibrary}),(PackageName "http-conduit",DepValue {dvVersionRange =
OrLaterVersion (mkVersion [0]), dvType = AsLibrary}),(PackageName
"http-types",DepValue {dvVersionRange = OrLaterVersion (mkVersion [0]), dvType =
AsLibrary}),(PackageName "immortal",DepValue {dvVersionRange = OrLaterVersion
(mkVersion [0]), dvType = AsLibrary}),(PackageName "jwt",DepValue
{dvVersionRange = OrLaterVersion (mkVersion [0]), dvType =
AsLibrary}),(PackageName "microlens-platform",DepValue {dvVersionRange =
OrLaterVersion (mkVersion [0]), dvType = AsLibrary}),(PackageName
"monad-logger",DepValue {dvVersionRange = OrLaterVersion (mkVersion [0]), dvType
= AsLibrary}),(PackageName "monad-validate",DepValue {dvVersionRange =
OrLaterVersion (mkVersion [0]), dvType = AsLibrary}),(PackageName
"optparse-applicative",DepValue {dvVersionRange = OrLaterVersion (mkVersion
[0]), dvType = AsLibrary}),(PackageName "relude",DepValue {dvVersionRange =
OrLaterVersion (mkVersion [0]), dvType = AsLibrary}),(PackageName
"resourcet",DepValue {dvVersionRange = OrLaterVersion (mkVersion [0]), dvType =
AsLibrary}),(PackageName "tagged",DepValue {dvVersionRange = OrLaterVersion
(mkVersion [0]), dvType = AsLibrary}),(PackageName "text",DepValue
{dvVersionRange = OrLaterVersion (mkVersion [0]), dvType =
AsLibrary}),(PackageName "time",DepValue {dvVersionRange = OrLaterVersion
(mkVersion [0]), dvType = AsLibrary}),(PackageName "tls",DepValue
{dvVersionRange = OrLaterVersion (mkVersion [0]), dvType =
AsLibrary}),(PackageName "typed-process",DepValue {dvVersionRange =
OrLaterVersion (mkVersion [0]), dvType = AsLibrary}),(PackageName
"unliftio",DepValue {dvVersionRange = OrLaterVersion (mkVersion [0]), dvType =
AsLibrary}),(PackageName "unliftio-core",DepValue {dvVersionRange =
OrLaterVersion (mkVersion [0]), dvType = AsLibrary})], packageUnknownTools =
fromList [], packageAllDeps = fromList [PackageName "Blammo",PackageName
"aeson",PackageName "amazonka",PackageName "amazonka-autoscaling",PackageName
"amazonka-sqs",PackageName "base",PackageName "bytestring",PackageName
"composition-extra",PackageName "conduit",PackageName
"conduit-extra",PackageName "data-default-class",PackageName
"envparse",PackageName "errors",PackageName "github",PackageName
"hedis",PackageName "http-conduit",PackageName "http-types",PackageName
"immortal",PackageName "jwt",PackageName "microlens-platform",PackageName
"monad-logger",PackageName "monad-validate",PackageName
"optparse-applicative",PackageName "relude",PackageName "resourcet",PackageName
"tagged",PackageName "text",PackageName "time",PackageName "tls",PackageName
"typed-process",PackageName "unliftio",PackageName "unliftio-core"],
packageGhcOptions = ["-Wall","-Werror","-O0"], packageCabalConfigOpts = [],
packageFlags = fromList [], packageDefaultFlags = fromList [], packageLibraries
= HasLibraries (fromList []), packageInternalLibraries = fromList [],
packageTests = fromList [], packageBenchmarks = fromList [], packageExes =
fromList ["agent"], packageOpts = <GetPackageOpts>, packageHasExposedModules =
True, packageBuildType = Simple, packageSetupDeps = Nothing, packageCabalSpec =
CabalSpecV1_12}) (fromList [(PackageName "monad-validate",(OrLaterVersion
(mkVersion [0]),Just (mkVersion
[1,2,0,1],5a100da896f11ca4b7c123da85decbedeb46c37054a097f258ac911e715cb68d,2587),NotInBuildPlan))]),UnknownPackage
(PackageName "monad-validate")]
"/home/patrick/code/restyled-io/agent/stack.yaml" "/home/patrick/.stack/"
(MonoidMap (fromList [(PackageName "Blammo",(First {getFirst =
Nothing},[(PackageIdentifier {pkgName = PackageName "agent", pkgVersion =
mkVersion [0,0,0,1]},OrLaterVersion (mkVersion [0]))])),(PackageName
"Cabal",(First {getFirst = Nothing},[(PackageIdentifier {pkgName = PackageName
"xml-conduit", pkgVersion = mkVersion [1,9,1,1]},OrLaterVersion (mkVersion
[0])),(PackageIdentifier {pkgName = PackageName "cabal-doctest", pkgVersion =
mkVersion [1,0,9]},IntersectVersionRanges (OrLaterVersion (mkVersion [1,10]))
(EarlierVersion (mkVersion [3,10]))),(PackageIdentifier {pkgName = PackageName
"entropy", pkgVersion = mkVersion [0,4,1,10]},IntersectVersionRanges
(OrLaterVersion (mkVersion [1,10])) (EarlierVersion (mkVersion
[3,9])))])),(PackageName "HTTP",(First {getFirst = Nothing},[(PackageIdentifier
{pkgName = PackageName "hedis", pkgVersion = mkVersion [0,15,1]},OrLaterVersion
(mkVersion [0]))])),(PackageName "OneTuple",(First {getFirst =
Nothing},[(PackageIdentifier {pkgName = PackageName "aeson", pkgVersion =
mkVersion [2,0,3,0]},IntersectVersionRanges (OrLaterVersion (mkVersion [0,3,1]))
(EarlierVersion (mkVersion [0,4]))),(PackageIdentifier {pkgName = PackageName
"indexed-traversable-instances", pkgVersion = mkVersion
[0,1,1,1]},IntersectVersionRanges (OrLaterVersion (mkVersion [0,3]))

{~2,000 more lines. I had to snip it here for GitHub to accept it}

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

Platform

Arch Linux

% uname -a
Linux pele 6.1.8-arch1-1 #1 SMP PREEMPT_DYNAMIC Tue, 24 Jan 2023 21:07:04 +0000 x86_64 GNU/Linux
simonmichael commented 1 year ago

+1, an unfortunate regression in the valuable --file-watch feature

mpilgrem commented 1 year ago

@pbrisbin, thanks for reporting. You are experiencing the same problem as in https://github.com/commercialhaskell/stack/issues/5978, and the problem has been fixed in Stack's master branch. If you want to get that Stack version now, stack upgrade --source-only --git should build and install it.

simonmichael commented 1 year ago

Thank you @mpilgrem !

pbrisbin commented 1 year ago

Awesome, thanks!