valderman / selda

A type-safe, high-level SQL library for Haskell
https://selda.link
MIT License
478 stars 58 forks source link

Failing to build `selda-sqlite` #172

Open guygastineau opened 2 years ago

guygastineau commented 2 years ago

I have used the sqlite backend with stack before, but know I am using cabal for a different project. It complains that the guarded packages are not available, but I am not using Haste.

I am using cabal version 3.6.0.0 Here is my cabal file:

cabal-version: 1.12

name:           corvid
version:        0.1.0.0
description:    Please see the README on GitHub at <https://github.com/EKULibraries/corvid#readme>
homepage:       https://github.com/EKULibraries/corvid#readme
bug-reports:    https://github.com/EKULibraries/corvid/issues
author:         Guy Gastineau
maintainer:     Guy.Gastineau@eku.edu
copyright:      2021 EKULibraries
license:        BSD3
license-file:   LICENSE
build-type:     Simple
extra-source-files:
    README.md
    ChangeLog.md

source-repository head
  type: git
  location: https://github.com/EKULibraries/corvid

library
  exposed-modules:
      EZProxy.Log
      EZProxy.Logs.Audit
      EZProxy.Logs.EZProxy
      EZProxy.Logs.Message
      EZProxy.Logs.Parse
      EZProxy.Logs.SPU
      EZProxy.Logs.Types
      LibChat.Config
      LibChat.Transcript
  hs-source-dirs:
      src
  build-depends:
      base             >=4.8   && <5
    , containers       >=0.6.5 && <0.7
    , ip               >=1.7.3 && <1.8
    , parsec           >=3.1   && <3.2
    , text             >=1.2   && <1.3
    , cassava          >=0.5.2 && <0.6
    , bytestring                  <0.12
    , aeson                       <2
    , time             >=1.9   && <1.13
    , filepath         >=1.4   && <1.5
    , directory        >=1.3   && <1.4
    , dhall            >=1.40  && <1.50
    , selda            >=0.5   && <0.6
  default-language: Haskell2010

executable corvid
  main-is: Main.hs
  hs-source-dirs:
      app/corvid
  ghc-options: -threaded -rtsopts -with-rtsopts=-N
  build-depends:
      base >=4.8 && <5
    , corvid <0.2
  default-language: Haskell2010

executable libchat-reader
    main-is: Main.hs
    hs-source-dirs:
        app/libchat-reader
    other-modules: Cli
    ghc-options: -threaded -rtsopts -with-rtsopts=-N
    build-depends:
        base                 >=4.8   && <5
      , corvid                          <0.2
      , cassava              >=0.5.2 && <0.6
      , bytestring                      <2
      , vector                          <0.13
      , aeson                           <2
      , utf8-string                     <1.1
      , optparse-applicative >=0.16  && <0.17
      , directory            >=1.3   && <1.4
      , split                >=0.2   && <0.3
      , selda                >=0.5   && <0.6
      , selda-sqlite         >=0.1   && <0.2
    default-language: Haskell2010

test-suite corvid-test
  type: exitcode-stdio-1.0
  main-is: Spec.hs
  other-modules:
      Paths_corvid
  hs-source-dirs:
      test
  ghc-options: -threaded -rtsopts -with-rtsopts=-N
  build-depends:
      base >=4.8 && <5
    , corvid <0.2
    , hspec
  default-language: Haskell2010

Here is the error I get when compiling.

Resolving dependencies...
Build profile: -w ghc-8.10.4 -O1
In order, the following will be built (use -v for more details):
 - selda-sqlite-0.1.7.1 (lib) (requires build)
 - corvid-0.1.0.0 (exe:libchat-reader) (configuration changed)
Starting     selda-sqlite-0.1.7.1 (lib)
Building     selda-sqlite-0.1.7.1 (lib)

Failed to build selda-sqlite-0.1.7.1.
Build log (
/home/guy/.cabal/logs/ghc-8.10.4/selda-sqlite-0.1.7.1-d2a9629e7a1939a6db1f842b87f13fe181e9a802abb72ba431a02f6a204e2f9a.log
):
Configuring library for selda-sqlite-0.1.7.1..
Preprocessing library for selda-sqlite-0.1.7.1..
Building library for selda-sqlite-0.1.7.1..
[1 of 2] Compiling Database.Selda.SQLite.Parser ( src/Database/Selda/SQLite/Parser.hs, dist/build/Database/Selda/SQLite/Parser.o, dist/build/Database/Selda/SQLite/Parser.dyn_o )
[2 of 2] Compiling Database.Selda.SQLite ( src/Database/Selda/SQLite.hs, dist/build/Database/Selda/SQLite.o, dist/build/Database/Selda/SQLite.dyn_o )

src/Database/Selda/SQLite.hs:15:1: error:
    Could not load module ‘Control.Monad.Catch’
    It is a member of the hidden package ‘exceptions-0.10.4’.
    Perhaps you need to add ‘exceptions’ to the build-depends in your .cabal file.
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
15 | import Control.Monad.Catch
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Database/Selda/SQLite.hs:16:1: error:
    Could not load module ‘Data.ByteString.Lazy’
    It is a member of the hidden package ‘bytestring-0.10.12.0’.
    Perhaps you need to add ‘bytestring’ to the build-depends in your .cabal file.
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
16 | import Data.ByteString.Lazy (toStrict)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Database/Selda/SQLite.hs:19:1: error:
    Could not load module ‘Data.Time’
    It is a member of the hidden package ‘time-1.9.3’.
    Perhaps you need to add ‘time’ to the build-depends in your .cabal file.
    It is a member of the hidden package ‘time-1.12’.
    Perhaps you need to add ‘time’ to the build-depends in your .cabal file.
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
19 | import Data.Time (FormatTime, formatTime, defaultTimeLocale)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Database/Selda/SQLite.hs:20:1: error:
    Could not load module ‘Data.UUID.Types’
    It is a member of the hidden package ‘uuid-types-1.0.5’.
    Perhaps you need to add ‘uuid-types’ to the build-depends in your .cabal file.
    It is a member of the hidden package ‘uuid-types-1.0.5’.
    Perhaps you need to add ‘uuid-types’ to the build-depends in your .cabal file.
    It is a member of the hidden package ‘uuid-types-1.0.5’.
    Perhaps you need to add ‘uuid-types’ to the build-depends in your .cabal file.
    It is a member of the hidden package ‘uuid-types-1.0.5’.
    Perhaps you need to add ‘uuid-types’ to the build-depends in your .cabal file.
    It is a member of the hidden package ‘uuid-types-1.0.5’.
    Perhaps you need to add ‘uuid-types’ to the build-depends in your .cabal file.
    It is a member of the hidden package ‘uuid-types-1.0.5’.
    Perhaps you need to add ‘uuid-types’ to the build-depends in your .cabal file.
    It is a member of the hidden package ‘uuid-types-1.0.4’.
    Perhaps you need to add ‘uuid-types’ to the build-depends in your .cabal file.
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
20 | import Data.UUID.Types (toByteString)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Database/Selda/SQLite.hs:21:1: error:
    Could not load module ‘Database.SQLite3’
    It is a member of the hidden package ‘direct-sqlite-2.3.26’.
    Perhaps you need to add ‘direct-sqlite’ to the build-depends in your .cabal file.
    It is a member of the hidden package ‘direct-sqlite-2.3.26’.
    Perhaps you need to add ‘direct-sqlite’ to the build-depends in your .cabal file.
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
21 | import Database.SQLite3
   | ^^^^^^^^^^^^^^^^^^^^^^^

src/Database/Selda/SQLite.hs:22:1: error:
    Could not load module ‘System.Directory’
    It is a member of the hidden package ‘directory-1.3.6.0’.
    Perhaps you need to add ‘directory’ to the build-depends in your .cabal file.
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
22 | import System.Directory (makeAbsolute)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cabal: Failed to build selda-sqlite-0.1.7.1 (which is required by
exe:libchat-reader from corvid-0.1.0.0). See the build log above for details.

I have poked around messing with flags to try fixing this, but I feel pretty stumped. The default value of the haste flag is set to false in the selda-sqlite.cabalc file, so I really don't know why this is happening. For cmpleteness here are the contents of my cabal.project packages: ./

I really appreciate any help.

guygastineau commented 2 years ago

The cabal file was originally created from a stack.yaml, but I am migrating away from stack. Still, it is a small file, and I believe I understand most of it. I don't think my cabal file is setting the haste flag in any way.

guygastineau commented 2 years ago

Well, I got it building. I had to pass --constraint "selda-sqlite -haste" to cabal build all to get it to build. I don't know why setting it universally didn't work, but anyway it seems somehow one of my other dependencies was setting the haste flag to true. I don't know how this would happen, and I expected cabal wouldn't let such a thing happen. I will comb my deps to try finding the offending package. Maybe I should open an issue with cabal if I can find the problem.

As the above indicates, I have at least a workaround for now, and the issue was never selda-sqlite's fault. If the maintainers would like I don't mind leaving this up until I resolve how it happens (perhaps with patches to cabal) in case someone else encounters this anomaly, but I will take no offense at closing it now, since the issue is not with your code. thank you.

tomjaguarpaw commented 11 months ago

Same here with selda-postgresql. I have to use

cabal build --constraint "selda-postgresql -haste"