packages feed

pantry 0.8.2.1 → 0.8.2.2

raw patch · 4 files changed

+309/−267 lines, 4 filesdep +networkPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

Dependencies added: network

API changes (from Hackage documentation)

+ Pantry: NoLocalPackageDirFound :: !Path Abs Dir -> PantryException

Files

ChangeLog.md view
@@ -1,5 +1,9 @@ # Changelog for pantry
 
+## v0.8.2.2
+
+* Add error S-395 (`NoLocalPackageDirFound`).
+
 ## v0.8.2.1
 
 * On Windows, avoid fatal `tar: Cannot connect to C: resolve failed` bug when
pantry.cabal view
@@ -1,266 +1,275 @@ cabal-version: 1.12
---- This file has been generated from package.yaml by hpack version 0.35.2.------ see: https://github.com/sol/hpack--name:           pantry-version:        0.8.2.1-synopsis:       Content addressable Haskell package management-description:    Please see the README on GitHub at <https://github.com/commercialhaskell/pantry#readme>-category:       Development-homepage:       https://github.com/commercialhaskell/pantry#readme-bug-reports:    https://github.com/commercialhaskell/pantry/issues-author:         Michael Snoyman-maintainer:     michael@snoyman.com-copyright:      2018-2022 FP Complete-license:        BSD3-license-file:   LICENSE-build-type:     Simple-extra-source-files:-    README.md-    ChangeLog.md-    attic/hpack-0.1.2.3.tar.gz-    attic/package-0.1.2.3.tar.gz-    attic/symlink-to-dir.tar.gz--source-repository head-  type: git-  location: https://github.com/commercialhaskell/pantry--flag test-pretty-exceptions-  description: Build an executable to test pretty exceptions-  manual: False-  default: False--library-  exposed-modules:-      Pantry-      Pantry.SHA256-      Pantry.Internal-      Pantry.Internal.StaticBytes-      Pantry.Internal.Stackage-      Pantry.Internal.Companion-      Pantry.Internal.AesonExtended-  other-modules:-      Hackage.Security.Client.Repository.HttpLib.HttpClient-      Pantry.Archive-      Pantry.HTTP-      Pantry.HPack-      Pantry.Hackage-      Pantry.Repo-      Pantry.SQLite-      Pantry.Storage-      Pantry.Casa-      Pantry.Tree-      Pantry.Types-  hs-source-dirs:-      src/-  ghc-options: -Wall-  build-depends:-      Cabal >=3 && <3.11-    , aeson-    , ansi-terminal-    , base >=4.10 && <5-    , bytestring-    , casa-client-    , casa-types-    , conduit-    , conduit-extra-    , containers-    , cryptonite-    , cryptonite-conduit-    , digest-    , filelock-    , generic-deriving-    , hackage-security-    , hpack >=0.35.1-    , http-client-    , http-client-tls-    , http-conduit-    , http-download-    , http-types-    , memory-    , mtl-    , network-uri-    , path-    , path-io-    , persistent-    , persistent-sqlite >=2.9.3-    , persistent-template-    , primitive-    , resourcet-    , rio-    , rio-orphans-    , rio-prettyprint-    , tar-conduit-    , text-    , text-metrics-    , time-    , transformers-    , unix-compat-    , unliftio-    , unordered-containers-    , vector-    , yaml-    , zip-archive-  default-language: Haskell2010-  if os(windows)-    other-modules:-        System.IsWindows-    hs-source-dirs:-        src/windows/-  else-    other-modules:-        System.IsWindows-    hs-source-dirs:-        src/unix/--executable test-pretty-exceptions-  main-is: Main.hs-  other-modules:-      Paths_pantry-  hs-source-dirs:-      app/test-pretty-exceptions-  ghc-options: -Wall-  build-depends:-      Cabal >=3 && <3.11-    , aeson-    , ansi-terminal-    , base >=4.10 && <5-    , bytestring-    , casa-client-    , casa-types-    , conduit-    , conduit-extra-    , containers-    , cryptonite-    , cryptonite-conduit-    , digest-    , filelock-    , generic-deriving-    , hackage-security-    , hpack >=0.35.1-    , http-client-    , http-client-tls-    , http-conduit-    , http-download-    , http-types-    , memory-    , mtl-    , network-uri-    , optparse-applicative-    , pantry-    , path-    , path-io-    , persistent-    , persistent-sqlite >=2.9.3-    , persistent-template-    , primitive-    , resourcet-    , rio-    , rio-orphans-    , rio-prettyprint-    , tar-conduit-    , text-    , text-metrics-    , time-    , transformers-    , unix-compat-    , unliftio-    , unordered-containers-    , vector-    , yaml-    , zip-archive-  default-language: Haskell2010-  if !flag(test-pretty-exceptions)-    buildable: False-  if os(windows)-    other-modules:-        PathAbsExamples-        System.Terminal-    hs-source-dirs:-        app/test-pretty-exceptions/windows/-    build-depends:-        Win32-      , process-  else-    other-modules:-        PathAbsExamples-        System.Terminal-    hs-source-dirs:-        app/test-pretty-exceptions/unix/--test-suite spec-  type: exitcode-stdio-1.0-  main-is: Spec.hs-  other-modules:-      Pantry.ArchiveSpec-      Pantry.BuildPlanSpec-      Pantry.CabalSpec-      Pantry.CasaSpec-      Pantry.FileSpec-      Pantry.GlobalHintsSpec-      Pantry.HackageSpec-      Pantry.Internal.StaticBytesSpec-      Pantry.InternalSpec-      Pantry.TreeSpec-      Pantry.TypesSpec-      Paths_pantry-  hs-source-dirs:-      test-  ghc-options: -Wall-  build-depends:-      Cabal >=3 && <3.11-    , QuickCheck-    , aeson-    , ansi-terminal-    , base >=4.10 && <5-    , bytestring-    , casa-client-    , casa-types-    , conduit-    , conduit-extra-    , containers-    , cryptonite-    , cryptonite-conduit-    , digest-    , exceptions-    , filelock-    , generic-deriving-    , hackage-security-    , hedgehog-    , hpack >=0.35.1-    , hspec-    , http-client-    , http-client-tls-    , http-conduit-    , http-download-    , http-types-    , memory-    , mtl-    , network-uri-    , pantry-    , path-    , path-io-    , persistent-    , persistent-sqlite >=2.9.3-    , persistent-template-    , primitive-    , raw-strings-qq-    , resourcet-    , rio-    , rio-orphans-    , rio-prettyprint-    , tar-conduit-    , text-    , text-metrics-    , time-    , transformers-    , unix-compat-    , unliftio-    , unordered-containers-    , vector-    , yaml-    , zip-archive-  default-language: Haskell2010+
+-- This file has been generated from package.yaml by hpack version 0.35.2.
+--
+-- see: https://github.com/sol/hpack
+
+name:           pantry
+version:        0.8.2.2
+synopsis:       Content addressable Haskell package management
+description:    Please see the README on GitHub at <https://github.com/commercialhaskell/pantry#readme>
+category:       Development
+homepage:       https://github.com/commercialhaskell/pantry#readme
+bug-reports:    https://github.com/commercialhaskell/pantry/issues
+author:         Michael Snoyman
+maintainer:     michael@snoyman.com
+copyright:      2018-2022 FP Complete
+license:        BSD3
+license-file:   LICENSE
+build-type:     Simple
+extra-source-files:
+    README.md
+    ChangeLog.md
+    attic/hpack-0.1.2.3.tar.gz
+    attic/package-0.1.2.3.tar.gz
+    attic/symlink-to-dir.tar.gz
+
+source-repository head
+  type: git
+  location: https://github.com/commercialhaskell/pantry
+
+flag test-pretty-exceptions
+  description: Build an executable to test pretty exceptions
+  manual: False
+  default: False
+
+library
+  exposed-modules:
+      Pantry
+      Pantry.SHA256
+      Pantry.Internal
+      Pantry.Internal.StaticBytes
+      Pantry.Internal.Stackage
+      Pantry.Internal.Companion
+      Pantry.Internal.AesonExtended
+  other-modules:
+      Hackage.Security.Client.Repository.HttpLib.HttpClient
+      Pantry.Archive
+      Pantry.HTTP
+      Pantry.HPack
+      Pantry.Hackage
+      Pantry.Repo
+      Pantry.SQLite
+      Pantry.Storage
+      Pantry.Casa
+      Pantry.Tree
+      Pantry.Types
+  hs-source-dirs:
+      src/
+  ghc-options: -Wall
+  build-depends:
+      Cabal >=3 && <3.11
+    , aeson
+    , ansi-terminal
+    , base >=4.10 && <5
+    , bytestring
+    , casa-client
+    , casa-types
+    , conduit
+    , conduit-extra
+    , containers
+    , cryptonite
+    , cryptonite-conduit
+    , digest
+    , filelock
+    , generic-deriving
+    , hackage-security
+    , hpack >=0.35.1
+    , http-client
+    , http-client-tls
+    , http-conduit
+    , http-download
+    , http-types
+    , memory
+    , mtl
+    , network-uri
+    , path
+    , path-io
+    , persistent
+    , persistent-sqlite >=2.9.3
+    , persistent-template
+    , primitive
+    , resourcet
+    , rio
+    , rio-orphans
+    , rio-prettyprint
+    , tar-conduit
+    , text
+    , text-metrics
+    , time
+    , transformers
+    , unix-compat
+    , unliftio
+    , unordered-containers
+    , vector
+    , yaml
+    , zip-archive
+  default-language: Haskell2010
+  if impl(ghc >= 9.4.5) && os(windows)
+    build-depends:
+        network >=3.1.2.9
+  if os(windows)
+    other-modules:
+        System.IsWindows
+    hs-source-dirs:
+        src/windows/
+  else
+    other-modules:
+        System.IsWindows
+    hs-source-dirs:
+        src/unix/
+
+executable test-pretty-exceptions
+  main-is: Main.hs
+  other-modules:
+      Paths_pantry
+  hs-source-dirs:
+      app/test-pretty-exceptions
+  ghc-options: -Wall
+  build-depends:
+      Cabal >=3 && <3.11
+    , aeson
+    , ansi-terminal
+    , base >=4.10 && <5
+    , bytestring
+    , casa-client
+    , casa-types
+    , conduit
+    , conduit-extra
+    , containers
+    , cryptonite
+    , cryptonite-conduit
+    , digest
+    , filelock
+    , generic-deriving
+    , hackage-security
+    , hpack >=0.35.1
+    , http-client
+    , http-client-tls
+    , http-conduit
+    , http-download
+    , http-types
+    , memory
+    , mtl
+    , network-uri
+    , optparse-applicative
+    , pantry
+    , path
+    , path-io
+    , persistent
+    , persistent-sqlite >=2.9.3
+    , persistent-template
+    , primitive
+    , resourcet
+    , rio
+    , rio-orphans
+    , rio-prettyprint
+    , tar-conduit
+    , text
+    , text-metrics
+    , time
+    , transformers
+    , unix-compat
+    , unliftio
+    , unordered-containers
+    , vector
+    , yaml
+    , zip-archive
+  default-language: Haskell2010
+  if impl(ghc >= 9.4.5) && os(windows)
+    build-depends:
+        network >=3.1.2.9
+  if !flag(test-pretty-exceptions)
+    buildable: False
+  if os(windows)
+    other-modules:
+        PathAbsExamples
+        System.Terminal
+    hs-source-dirs:
+        app/test-pretty-exceptions/windows/
+    build-depends:
+        Win32
+      , process
+  else
+    other-modules:
+        PathAbsExamples
+        System.Terminal
+    hs-source-dirs:
+        app/test-pretty-exceptions/unix/
+
+test-suite spec
+  type: exitcode-stdio-1.0
+  main-is: Spec.hs
+  other-modules:
+      Pantry.ArchiveSpec
+      Pantry.BuildPlanSpec
+      Pantry.CabalSpec
+      Pantry.CasaSpec
+      Pantry.FileSpec
+      Pantry.GlobalHintsSpec
+      Pantry.HackageSpec
+      Pantry.Internal.StaticBytesSpec
+      Pantry.InternalSpec
+      Pantry.TreeSpec
+      Pantry.TypesSpec
+      Paths_pantry
+  hs-source-dirs:
+      test
+  ghc-options: -Wall
+  build-depends:
+      Cabal >=3 && <3.11
+    , QuickCheck
+    , aeson
+    , ansi-terminal
+    , base >=4.10 && <5
+    , bytestring
+    , casa-client
+    , casa-types
+    , conduit
+    , conduit-extra
+    , containers
+    , cryptonite
+    , cryptonite-conduit
+    , digest
+    , exceptions
+    , filelock
+    , generic-deriving
+    , hackage-security
+    , hedgehog
+    , hpack >=0.35.1
+    , hspec
+    , http-client
+    , http-client-tls
+    , http-conduit
+    , http-download
+    , http-types
+    , memory
+    , mtl
+    , network-uri
+    , pantry
+    , path
+    , path-io
+    , persistent
+    , persistent-sqlite >=2.9.3
+    , persistent-template
+    , primitive
+    , raw-strings-qq
+    , resourcet
+    , rio
+    , rio-orphans
+    , rio-prettyprint
+    , tar-conduit
+    , text
+    , text-metrics
+    , time
+    , transformers
+    , unix-compat
+    , unliftio
+    , unordered-containers
+    , vector
+    , yaml
+    , zip-archive
+  default-language: Haskell2010
+  if impl(ghc >= 9.4.5) && os(windows)
+    build-depends:
+        network >=3.1.2.9
src/Pantry.hs view
@@ -239,6 +239,7 @@ import Data.Yaml.Include (decodeFileWithWarnings)
 import Hpack.Yaml (formatWarning)
 import Hpack.Error (formatHpackError)
+import System.IO.Error (isDoesNotExistError)
 
 decodeYaml :: FilePath -> IO (Either String ([String], Value))
 decodeYaml file = do
@@ -732,8 +733,10 @@ findOrGenerateCabalFile progName pkgDir = do
     let hpackProgName = fromString . unpack <$> progName
     hpack hpackProgName pkgDir
-    files <- filter (flip hasExtension "cabal" . toFilePath) . snd
-         <$> listDir pkgDir
+    (_, allFiles) <- listDir pkgDir `catchIO` \e -> if isDoesNotExistError e
+      then throwIO $ NoLocalPackageDirFound pkgDir
+      else throwIO e
+    let files = filter (flip hasExtension "cabal" . toFilePath) allFiles
     -- If there are multiple files, ignore files that start with
     -- ".". On unixlike environments these are hidden, and this
     -- character is not valid in package names. The main goal is
src/Pantry/Types.hs view
@@ -966,6 +966,7 @@   | TreeWithoutCabalFile !RawPackageLocationImmutable
   | TreeWithMultipleCabalFiles !RawPackageLocationImmutable ![SafeFilePath]
   | MismatchedCabalName !(Path Abs File) !PackageName
+  | NoLocalPackageDirFound !(Path Abs Dir)
   | NoCabalFileFound !(Path Abs Dir)
   | MultipleCabalFilesFound !(Path Abs Dir) ![Path Abs File]
   | InvalidWantedCompiler !Text
@@ -1086,6 +1087,15 @@     <> ".cabal\n"
     <> "Hackage rejects packages where the first part of the Cabal file name "
     <> "is not the package name."
+  display (NoLocalPackageDirFound dir) =
+    "Error: [S-395]\n"
+    <> "Stack looks for packages in the directories configured in\n"
+    <> "the 'packages' and 'extra-deps' fields defined in your stack.yaml\n"
+    <> "The current entry points to "
+    <> fromString (toFilePath dir)
+    <> ",\nbut no such directory could be found. If, alternatively, a package\n"
+    <> "in the package index was intended, its name and version must be\n"
+    <> "specified as an extra-dep."
   display (NoCabalFileFound dir) =
     "Error: [S-636]\n"
     <> "Stack looks for packages in the directories configured in\n"
@@ -1421,6 +1431,22 @@          , style File (fromString $ packageNameString name <> ".cabal") <> "."
          , flow "Hackage rejects packages where the first part of the Cabal"
          , flow "file name is not the package name."
+         ]
+  pretty (NoLocalPackageDirFound dir) =
+    "[S-395]"
+    <> line
+    <> fillSep
+         [ flow "Stack looks for packages in the directories configured in the"
+         , style Shell "packages"
+         , "and"
+         , style Shell "extra-deps"
+         , flow "fields defined in your"
+         , style File "stack.yaml" <> "."
+         , flow "The current entry points to"
+         , pretty dir
+         , flow "but no such directory could be found. If, alternatively, a"
+         , flow "package in the package index was intended, its name and"
+         , flow "version must be specified as an extra-dep."
          ]
   pretty (NoCabalFileFound dir) =
     "[S-636]"