From 1f6818dd949f99a2e7dd7e6a39dccc686b0db038 Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Tue, 24 Sep 2024 01:00:44 +0300 Subject: [PATCH] Make "missing packages" error message more descriptive Currently there exists confusion due to Pursuit now showing package sets that include a package. IOW it always looks as if every package on Pursuit available on every "package set" from the registry. As result, when a user receives error message from Spago that says that a package wasn't found, unless a user already knows this situation, they unlikely would think it's a problem on the remote side rather than with syntax or something similar. But on the `spago` side we can reduce confusion by showing a user a message hinting that it is possible to enlist available packages with `spago ls packages`. Fixes: https://github.com/purescript/spago/issues/1287 --- src/Spago/Command/Fetch.purs | 4 +++- test-fixtures/missing-dependencies.txt | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Spago/Command/Fetch.purs b/src/Spago/Command/Fetch.purs index 29c2f3bb0..b63919608 100644 --- a/src/Spago/Command/Fetch.purs +++ b/src/Spago/Command/Fetch.purs @@ -725,7 +725,9 @@ getTransitiveDepsFromPackageSet packageSet deps = do when (not (Set.isEmpty errors.cycle)) do die $ "The following packages have circular dependencies:\n" <> foldMap printPackageError (Set.toUnfoldable errors.cycle :: Array PackageName) when (not (Set.isEmpty errors.notInPackageSet)) do - die $ "The following packages do not exist in your package set:\n" <> foldMap printNotInPackageSetError errors.notInPackageSet + die $ "The following packages do not exist in your package set:\n" + <> foldMap printNotInPackageSetError errors.notInPackageSet + <> "To list available packages use `spago ls packages`\n" when (not (Set.isEmpty errors.notInIndex)) do die $ "The following packages do not exist in the package index:\n" <> foldMap printPackageError errors.notInIndex pure packages diff --git a/test-fixtures/missing-dependencies.txt b/test-fixtures/missing-dependencies.txt index 9636c9243..1afff7ccd 100644 --- a/test-fixtures/missing-dependencies.txt +++ b/test-fixtures/missing-dependencies.txt @@ -8,3 +8,4 @@ Reading Spago workspace configuration... - bar-bar-bar - effcet (did you mean: effect) - foo-foo-foo +To list available packages use `spago ls packages`