无法构建mysql-haskell库

问题描述 投票:0回答:1

我无法使用不同版本的haskell安装mysql-haskell lib,我尝试9.8.2 9.6.6 和 9.4.8,其中两个在堆栈快照中提供https://www.stackage.org/package/mysql-haskell/snapshots - 所以我希望如果我使用相应的版本,它必须一起工作cabal 和 docker,但实际上这并没有发生,我做错了什么以及如何修复它?

ps。我还发现 20 天前我的容器是使用相同的配置构建的,没有错误,所以我现在可以运行它并在控制台中查看:

 "Warning: The package list for 'hackage.haskell.org' is 20 days old.
hservant-1  | Run 'cabal update' to get the latest list of available packages.
",

但现在我猜新版本中的阴谋集团更新带来了这个错误..

这是我的码头工

FROM haskell:9.8.2
#FROM haskell:9.6.6
#FROM haskell:9.4.8

WORKDIR /opt/p1

RUN cabal update && cabal install haskell-language-server

# Add just the .cabal file to capture dependencies
COPY ./herror.cabal /opt/p1/herror.cabal

# Docker will cache this command as a layer, freeing us up to
# modify source code without re-installing dependencies
# (unless the .cabal file changes!)
RUN cabal build --only-dependencies -j4
#RUN cabal v2-install --only-dependencies -j4

# Add and Install Application Code
COPY . /opt/p1
RUN cabal install

#CMD ["p1"]
CMD ["cabal", "run"]

这是我的 p1.cabal

cabal-version:      3.0
name:               p1    
version:            0.1.0.0
license:            NONE   
author:             dmitr
maintainer:         [email protected]
build-type:         Simple
extra-doc-files:    CHANGELOG.md

common warnings
    ghc-options: -Wall

executable p1
    import:           warnings
    main-is:          Main.hs
    build-depends:    base,
                      -- base ^>=4.17.2.1,
                      -- tls==1.5.8,
                      mysql-haskell==1.1.6

    hs-source-dirs:   app    
    default-language: Haskell2010

我收到此错误:

265.1 [17 of 24] Compiling Paths_mysql_haskell ( dist/build/autogen/Paths_mysql_haskell.hs, dist/build/Paths_mysql_haskell.o, dist/build/Paths_mysql_haskell.dyn_o )
265.1 [18 of 24] Compiling Data.TLSSetting  ( src/Data/TLSSetting.hs, dist/build/Data/TLSSetting.o, dist/build/Data/TLSSetting.dyn_o )
265.1 
265.1 src/Data/TLSSetting.hs:70:35: error: [GHC-39999]
265.1     • No instance for ‘Data.Default.Class.Default TLS.Supported’
265.1         arising from a use of ‘def’
265.1     • In the expression: def
265.1       In a record update at field ‘TLS.supportedCiphers’,
265.1       with type constructor ‘TLS.Supported’
265.1       and data constructor ‘tls-2.1.4:Network.TLS.Parameters.Supported’.
265.1       In the expression:
265.1         def {TLS.supportedCiphers = TLS.ciphersuite_default}
265.1    |
265.1 70 |         {   TLS.clientSupported = def { TLS.supportedCiphers = TLS.ciphersuite_default }
265.1    |                                   ^^^
265.1 
265.1 src/Data/TLSSetting.hs:71:35: error: [GHC-39999]
265.1     • No instance for ‘Data.Default.Class.Default TLS.Shared’
265.1         arising from a use of ‘def’
265.1     • In the expression: def
265.1       In a record update at fields ‘TLS.sharedCAStore’,
265.1                                    ‘TLS.sharedValidationCache’,
265.1       with type constructor ‘TLS.Shared’
265.1       and data constructor ‘tls-2.1.4:Network.TLS.Parameters.Shared’.
265.1       In the expression:
265.1         def {TLS.sharedCAStore = caStore, TLS.sharedValidationCache = def}
265.1    |
265.1 71 |         ,   TLS.clientShared    = def
265.1    |                                   ^^^
265.1 
265.1 src/Data/TLSSetting.hs:73:45: error: [GHC-39999]
265.1     • No instance for ‘Data.Default.Class.Default TLS.ValidationCache’
265.1         arising from a use of ‘def’
265.1     • In the expression: def
265.1       In a record update at fields ‘TLS.sharedCAStore’,
265.1                                    ‘TLS.sharedValidationCache’,
265.1       with type constructor ‘TLS.Shared’
265.1       and data constructor ‘tls-2.1.4:Network.TLS.Parameters.Shared’.
265.1       In the expression:
265.1         def {TLS.sharedCAStore = caStore, TLS.sharedValidationCache = def}
265.1    |
265.1 73 |             ,   TLS.sharedValidationCache = def
265.1    |                                             ^^^
265.1 
265.1 src/Data/TLSSetting.hs:115:20: error: [GHC-39999]
265.1     • No instance for ‘Data.Default.Class.Default TLS.ServerParams’
265.1         arising from a use of ‘def’
265.1     • In the expression: def
265.1       In a record update at fields ‘TLS.serverCACertificates’,
265.1                                    ‘TLS.serverShared’, ‘TLS.serverSupported’,
265.1       with type constructor ‘TLS.ServerParams’
265.1       and data constructor ‘tls-2.1.4:Network.TLS.Parameters.ServerParams’.
265.1       In the first argument of ‘return’, namely
265.1         ‘def
265.1            {TLS.serverCACertificates = c'',
265.1             TLS.serverShared = def
265.1                                  {TLS.sharedCredentials = TLS.Credentials [c']},
265.1             TLS.serverSupported = def
265.1                                     {TLS.supportedCiphers = TLS.ciphersuite_strong}}’
265.1     |
265.1 115 |             return def
265.1     |                    ^^^
265.1 [19 of 24] Compiling System.IO.Streams.TCP ( src/System/IO/Streams/TCP.hs, dist/build/System/IO/Streams/TCP.o, dist/build/System/IO/Streams/TCP.dyn_o )
265.1 [20 of 24] Compiling Database.MySQL.Connection ( src/Database/MySQL/Connection.hs, dist/build/Database/MySQL/Connection.o, dist/build/Database/MySQL/Connection.dyn_o )
265.1 [21 of 24] Compiling Database.MySQL.Base ( src/Database/MySQL/Base.hs, dist/build/Database/MySQL/Base.o, dist/build/Database/MySQL/Base.dyn_o )
265.1 [22 of 24] Compiling Database.MySQL.BinLog ( src/Database/MySQL/BinLog.hs, dist/build/Database/MySQL/BinLog.o, dist/build/Database/MySQL/BinLog.dyn_o )
265.1 Error: cabal: Failed to build mysql-haskell-1.1.6. See the build log above for
265.1 details.
265.1 
------
Dockerfile:15
--------------------
  13 |     # modify source code without re-installing dependencies
  14 |     # (unless the .cabal file changes!)
  15 | >>> RUN cabal build --only-dependencies -j4
  16 |     #RUN cabal v2-install --only-dependencies -j4
  17 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c cabal build --only-dependencies -j4" did not complete successfully: exit code: 1

我尝试降级到 mysql-haskell==1.5.0 及更低版本,但这总是涉及 tls lib 构建错误,例如:

174.8 [38 of 76] Compiling Network.TLS.Credentials ( Network/TLS/Credentials.hs, dist/build/Network/TLS/Credentials.o, dist/build/Network/TLS/Credentials.dyn_o )
174.8 [39 of 76] Compiling Network.TLS.Parameters ( Network/TLS/Parameters.hs, dist/build/Network/TLS/Parameters.o, dist/build/Network/TLS/Parameters.dyn_o )
174.8 
174.8 Network/TLS/Parameters.hs:404:39: error: [GHC-39999]
174.8     • No instance for ‘Default ValidationCache’
174.8         arising from a use of ‘def’
174.8     • In the ‘sharedValidationCache’ field of a record
174.8       In the expression:
174.8         Shared
174.8           {sharedCredentials = mempty,
174.8            sharedSessionManager = noSessionManager, sharedCAStore = mempty,
174.8            sharedValidationCache = def, sharedHelloExtensions = []}
174.8       In an equation for ‘def’:
174.8           def
174.8             = Shared
174.8                 {sharedCredentials = mempty,
174.8                  sharedSessionManager = noSessionManager, sharedCAStore = mempty,
174.8                  sharedValidationCache = def, sharedHelloExtensions = []}
174.8     |
174.8 404 |             , sharedValidationCache = def
174.8     |                                       ^^^
174.8 Error: cabal: Failed to build tls-2.0.6 (which is required by
174.8 mysql-haskell-1.1.5). See the build log above for details.
174.8 
------
Dockerfile:15
--------------------
  13 |     # modify source code without re-installing dependencies
  14 |     # (unless the .cabal file changes!)
  15 | >>> RUN cabal build --only-dependencies -j4
  16 |     #RUN cabal v2-install --only-dependencies -j4
  17 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c cabal build --only-dependencies -j4" did not complete successfully: exit code: 1

有趣的是 tls lib 本身是在没有 mysql-haskell 的情况下构建的,但后来我添加了 mysql-haskell 我得到了所有这些错误。

haskell mysql-connector
1个回答
0
投票

这些

Default
错误是因为
Default
类存在重复副本:一份来自较新版本的包
data-default
(
>= 0.8
),一份来自旧版本的
data-default-class
(
< 0.2
)。

您需要保持同步:仅使用旧版本或仅使用新版本的

data-default
data-default-class

mysql-haskell
具有依赖性
data-default-class < 0.2
,因此我建议将
data-default < 0.8
添加到您的包中。

另一种解决方案可能是通过忽略上限并添加下限来要求新版本

data-default-class >= 0.2 && data-default >= 0.8

© www.soinside.com 2019 - 2024. All rights reserved.