haskell / cabal

Official upstream development repository for Cabal and cabal-install
https://haskell.org/cabal
Other
1.62k stars 697 forks source link

cabal after using freeze cannot resolve dependency on different computer #9021

Closed andrewufrank closed 1 year ago

andrewufrank commented 1 year ago

Describe the bug

I have used cabal freeze on a computer and try to build the same program on another computer. I understand that cabal build should compile now the exact same configuration, but I encounter a conflict. The start of the error is:

cabal v2-build
Resolving dependencies...
Error: cabal: Could not resolve dependencies:
[__0] trying: daino-0.1.5.3.1 (user goal)
[__1] trying: unix-2.7.2.2/installed-2.7.2.2 (dependency of daino)
[__2] next goal: bytestring (dependency of unix)
[__2] rejecting: bytestring-0.11.3.1/installed-0.11.3.1 (constraint from
project config /home/frank/Workspace11/daino/cabal.project.freeze requires
==0.11.4.0)
[__2] rejecting: bytestring-0.11.4.0 (conflict: unix =>
bytestring==0.11.3.1/installed-0.11.3.1)
[__2] rejecting: bytestring-0.11.3.1, bytestring-0.11.3.0,
bytestring-0.11.2.0, bytestring-0.11.1.0, bytestring-0.11.0.0,
bytestring-0.10.12.1, bytestring-0.10.12.0, bytestring-0.10.10.1,
bytestring-0.10.10.0, bytestring-0.10.9.0, byte

I cannot understand the error. It should install unix-2.7.2.2 which requires bytestring <0.12 and the freeze asks for any.bytestring ==0.11.4.0,.

why does cabal build not try 0.11.4.0 but rejects 0.11.3.1? It should not matter, that 0.11.3.1 is installed?

What is my misconception of freeze? Thank you for help!

To Reproduce on a third computer it builds with the same freeze file, but I cannot see what bytestring is installed - I have not much experience with the internal structures of cabal. I checked in .cabal/log and .cabal/packages and cannot find an entry for bytestring neither on the machine it builds nor on the one it cannot resolve dependencies..

System information

Additional context

the freeze file is:

constraints: any.Cabal ==3.6.3.0, any.Diff ==0.4.1, any.Glob ==0.10.2, any.HTF ==0.15.0.1, any.HUnit ==1.6.2.0, any.JuicyPixels ==3.3.8, JuicyPixels -mmap, any.MissingH ==1.6.0.0, MissingH +network--ge-3_0_0, any.OneTuple ==0.4.1.1, any.QuickCheck ==2.14.3, QuickCheck -old-random +templatehaskell, any.ReplaceUmlaut ==0.1.5.3, any.SHA ==1.6.4.4, SHA -exe, any.StateVar ==1.2.2, any.adjunctions ==4.4.2, any.aeson ==2.1.2.1, aeson -cffi +ordered-keymap, any.aeson-pretty ==0.8.9, aeson-pretty -lib-only, any.ansi-terminal ==1.0, ansi-terminal -example, any.ansi-terminal-types ==0.11.5, any.appar ==0.1.8, any.array ==0.5.4.0, any.asn1-encoding ==0.9.6, any.asn1-parse ==0.9.5, any.asn1-types ==0.3.4, any.assoc ==1.1, assoc +tagged, any.async ==2.2.4, async -bench, any.attoparsec ==0.14.4, attoparsec -developer, any.auto-update ==0.1.6, any.base ==4.16.4.0, any.base-compat ==0.13.0, any.base-compat-batteries ==0.13.0, any.base-orphans ==0.9.0, any.base16-bytestring ==1.0.2.0, any.base64 ==0.4.2.4, any.base64-bytestring ==1.2.1.0, any.basement ==0.0.15, any.bifunctors ==5.6.1, bifunctors +tagged, any.binary ==0.8.9.0, any.bitvec ==1.1.4.0, bitvec -libgmp, any.blaze-builder ==0.4.2.2, any.blaze-html ==0.9.1.2, any.blaze-markup ==0.8.2.8, any.bsb-http-chunked ==0.0.0.4, any.byteorder ==1.0.4, any.bytestring ==0.11.4.0, any.bytestring-builder ==0.10.8.2.0, bytestring-builder +bytestring_has_builder, any.cabal-doctest ==1.0.9, any.call-stack ==0.4.0, any.case-insensitive ==1.2.1.0, any.cereal ==0.5.8.3, cereal -bytestring-builder, any.citeproc ==0.8.1, citeproc -executable -icu, any.clock ==0.8.3, clock -llvm, any.cmdargs ==0.10.22, cmdargs +quotation -testprog, any.colour ==2.3.6, any.commonmark ==0.2.2, any.commonmark-extensions ==0.2.3.4, any.commonmark-pandoc ==0.2.1.3, any.comonad ==5.0.8, comonad +containers +distributive +indexed-traversable, any.conduit ==1.3.5, any.conduit-extra ==1.3.6, any.connection ==0.3.1, any.constraints ==0.13.4, any.containers ==0.6.5.1, any.contravariant ==1.5.5, contravariant +semigroups +statevar +tagged, any.convertible ==1.1.1.1, any.cookie ==0.4.6, any.cpphs ==1.20.9.1, cpphs -old-locale, any.crypto-api ==0.13.3, crypto-api -all_cpolys, any.cryptohash-sha1 ==0.11.101.0, any.cryptonite ==0.30, cryptonite -check_alignment +integer-gmp -old_toolchain_inliner +support_aesni +support_deepseq -support_pclmuldq +support_rdrand -support_sse +use_target_attributes, any.data-array-byte ==0.1.0.1, any.data-default ==0.7.1.1, any.data-default-class ==0.1.2.0, any.data-default-instances-containers ==0.0.1, any.data-default-instances-dlist ==0.0.1, any.data-default-instances-old-locale ==0.0.1, any.data-fix ==0.3.2, any.deepseq ==1.4.6.1, any.digest ==0.0.1.7, digest +pkg-config, any.dir-traverse ==0.2.3.0, any.directory ==1.3.6.2, any.distributive ==0.6.2.1, distributive +semigroups +tagged, any.dlist ==1.0, dlist -werror, any.doclayout ==0.4.0.1, any.doctemplates ==0.11, any.easy-file ==0.2.5, any.emojis ==0.1.2, any.enclosed-exceptions ==1.0.3, any.entropy ==0.4.1.10, entropy -donotgetentropy, any.exceptions ==0.10.4, any.expiring-cache-map ==0.0.6.1, any.extra ==1.7.13, any.fast-logger ==3.2.1, any.file-embed ==0.0.15.0, any.filepath ==1.4.2.2, any.filepattern ==0.1.3, any.foldable1-classes-compat ==0.1, foldable1-classes-compat +tagged, any.free ==5.2, any.fsnotify ==0.3.0.1, any.generically ==0.1.1, any.ghc-bignum ==1.2, any.ghc-boot-th ==9.2.7, any.ghc-prim ==0.8.0, any.gridtables ==0.1.0.0, any.haddock-library ==1.11.0, any.happy ==1.20.1.1, any.hashable ==1.4.2.0, hashable +integer-gmp -random-initial-seed, any.haskell-lexer ==1.1.1, any.haskell-src ==1.0.4, any.heaps ==0.4, any.hinotify ==0.4.1, any.hourglass ==0.2.12, any.hsc2hs ==0.68.9, hsc2hs -in-ghc-tree, any.hslogger ==1.3.1.0, hslogger +network--gt-3_0_0, any.http-client ==0.7.13.1, http-client +network-uri, any.http-client-tls ==0.3.6.1, any.http-conduit ==2.3.8, http-conduit +aeson, any.http-date ==0.0.11, any.http-types ==0.12.3, any.http2 ==4.1.2, http2 -devel -h2spec, any.indexed-traversable ==0.1.2.1, any.indexed-traversable-instances ==0.1.1.2, any.integer-gmp ==1.1, any.integer-logarithms ==1.0.3.1, integer-logarithms -check-bounds +integer-gmp, any.invariant ==0.6.1, any.io-streams ==1.5.2.2, io-streams +network -nointeractivetests +zlib, any.iproute ==1.7.12, any.ipynb ==0.2, any.jira-wiki-markup ==1.5.1, any.js-dgtable ==0.5.2, any.js-flot ==0.8.3, any.js-jquery ==3.3.1, any.kan-extensions ==5.2.5, any.lens ==5.2.2, lens -benchmark-uniplate -dump-splices +inlining -j +test-hunit +test-properties +test-templates +trustworthy, any.lens-aeson ==1.2.2, any.libyaml ==0.1.2, libyaml -no-unicode -system-libyaml, any.lifted-async ==0.10.2.4, any.lifted-base ==0.2.3.12, any.memory ==0.18.0, memory +support_bytestring +support_deepseq, any.mime-types ==0.1.1.0, any.mmorph ==1.2.0, any.monad-control ==1.0.3.1, any.monads-tf ==0.1.0.3, any.mono-traversable ==1.0.15.3, any.mtl ==2.2.2, any.network ==3.1.4.0, network -devel, any.network-bsd ==2.8.1.0, any.network-byte-order ==0.1.6, any.network-uri ==2.6.4.2, any.non-negative ==0.1.2, non-negative +splitbase, any.numeric-prelude ==0.4.4, numeric-prelude -buildexamples, any.old-locale ==1.0.0.7, any.old-time ==1.1.0.3, any.optparse-applicative ==0.18.1.0, optparse-applicative +process, any.pandoc ==3.1.2, pandoc -embed_data_files, any.pandoc-sidenote ==0.23.0.0, any.pandoc-types ==1.23, any.parallel ==3.2.2.0, any.parsec ==3.1.15.0, any.path ==0.9.2, path -dev, any.path-io ==1.8.1, path-io -dev, any.pem ==0.2.4, any.pipes ==4.3.16, any.polyparse ==1.13, any.pretty ==1.1.3.6, any.pretty-show ==1.10, any.prettyprinter ==1.7.1, prettyprinter -buildreadme +text, any.prettyprinter-ansi-terminal ==1.1.3, any.primitive ==0.8.0.0, any.process ==1.6.16.0, any.profunctors ==5.6.2, any.psqueues ==0.2.7.3, any.pureMD5 ==2.1.4, pureMD5 -test, any.quickcheck-text ==0.1.2.1, any.random ==1.2.1.1, any.readable ==0.3.1, any.recv ==0.1.0, any.reflection ==2.1.7, reflection -slow +template-haskell, any.regex-base ==0.94.0.2, any.regex-compat ==0.95.2.1, any.regex-posix ==0.96.0.1, regex-posix -_regex-posix-clib, any.resourcet ==1.3.0, any.rts ==1.0.2, any.safe ==0.3.19, any.safe-exceptions ==0.1.7.3, any.scientific ==0.3.7.0, scientific -bytestring-builder -integer-simple, any.scotty ==0.12.1, any.semialign ==1.3, semialign +semigroupoids, any.semigroupoids ==6.0.0.1, semigroupoids +comonad +containers +contravariant +distributive +tagged +unordered-containers, any.semigroups ==0.20, semigroups +binary +bytestring -bytestring-builder +containers +deepseq +hashable +tagged +template-haskell +text +transformers +unordered-containers, any.shake ==0.19.7, shake -cloud -embed-files -portable, any.shelly ==1.12.1, shelly -build-examples -lifted, any.silently ==1.2.5.3, any.simple-sendfile ==0.2.31, simple-sendfile +allow-bsd -fallback, any.skylighting ==0.13.2.1, skylighting -executable, any.skylighting-core ==0.13.2.1, skylighting-core -executable, any.skylighting-format-ansi ==0.1, any.skylighting-format-blaze-html ==0.1.1, any.skylighting-format-context ==0.1.0.2, any.skylighting-format-latex ==0.1, any.snap-core ==1.0.5.1, snap-core -debug +network-uri -portable, any.socks ==0.6.1, any.split ==0.2.3.5, any.splitmix ==0.1.0.4, splitmix -optimised-mixer, any.stm ==2.5.0.2, any.storable-record ==0.0.7, storable-record -buildtests +splitbase, any.streaming-commons ==0.2.2.6, streaming-commons -use-bytestring-builder, any.strict ==0.5, any.syb ==0.7.2.3, any.tagged ==0.8.7, tagged +deepseq +transformers, any.tagsoup ==0.14.8, any.template-haskell ==2.18.0.0, any.temporary ==1.3, any.test-invariant ==0.4.5.0, any.texmath ==0.12.7.1, texmath -executable -server, any.text ==1.2.5.0, any.text-conversions ==0.3.1.1, any.text-short ==0.1.5, text-short -asserts, any.th-abstraction ==0.5.0.0, any.th-compat ==0.1.4, any.th-lift ==0.8.3, any.th-lift-instances ==0.1.20, any.these ==1.2, any.time ==1.11.1.1, any.time-compat ==1.9.6.1, time-compat -old-locale, any.time-manager ==0.0.0, any.tls ==1.6.0, tls +compat -hans +network, any.transformers ==0.5.6.2, any.transformers-base ==0.4.6, transformers-base +orphaninstances, any.transformers-compat ==0.7.2, transformers-compat -five +five-three -four +generic-deriving +mtl -three -two, any.twitch ==0.1.7.2, any.type-equality ==1, any.typed-process ==0.2.11.0, any.unicode-collation ==0.1.3.4, unicode-collation -doctests -executable, any.unicode-data ==0.4.0.1, unicode-data -ucd2haskell, any.unicode-transforms ==0.4.0.1, unicode-transforms -bench-show -dev -has-icu -has-llvm -use-gauge, any.uniform-algebras ==0.1.5.1, any.uniform-error ==0.1.5.1, any.uniform-http ==0.1.5.1, any.uniform-shake ==0.1.5.1, any.uniform-strings ==0.1.5.1, any.uniform-time ==0.1.5.1, any.uniform-watch ==0.1.5.1, any.uniform-webserver ==0.1.5.1, any.uniformBase ==0.1.5.1, any.uniplate ==1.6.13, any.unix ==2.7.2.2, any.unix-compat ==0.7, unix-compat -old-time, any.unix-time ==0.4.9, any.unliftio ==0.2.24.0, any.unliftio-core ==0.2.1.0, any.unordered-containers ==0.2.19.1, unordered-containers -debug, any.utf8-string ==1.0.2, any.utility-ht ==0.0.17, any.uuid-types ==1.0.5, any.vault ==0.3.1.5, vault +useghc, any.vector ==0.13.0.0, vector +boundschecks -internalchecks -unsafechecks -wall, any.vector-algorithms ==0.9.0.1, vector-algorithms +bench +boundschecks -internalchecks -llvm +properties -unsafechecks, any.vector-stream ==0.1.0.0, any.void ==0.7.3, void -safe, any.wai ==3.2.3, any.wai-extra ==3.1.13.0, wai-extra -build-example, any.wai-logger ==2.4.0, any.wai-middleware-static ==0.9.2, any.warp ==3.3.25, warp +allow-sendfilefd -network-bytestring -warp-debug +x509, any.witherable ==0.4.2, any.word8 ==0.1.3, any.x509 ==1.7.7, any.x509-store ==1.6.9, any.x509-system ==1.6.7, any.x509-validation ==1.6.12, any.xml ==1.3.14, any.xml-conduit ==1.9.1.2, any.xml-types ==0.3.8, any.xmlgen ==0.6.2.2, any.yaml ==0.11.11.0, yaml +no-examples +no-exe, any.zip-archive ==0.4.3, zip-archive -executable, any.zlib ==0.6.3.0, zlib -bundled-c-zlib -non-blocking-ffi -pkg-config, any.zlib-bindings ==0.1.1.5 index-state: hackage.haskell.org 2023-06-05T00:16:01Z

and the daino.cabal is:

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: daino version: 0.1.5.3.1 synopsis: daino is a static site generator (SSG) using shake and pandoc description: A static site generator using Pandoc and other available packages on Hackage (e.g. shake, twitch, scotty), influenced by Chris Penner's slick. It uses text files (in Markdown codes) to manage data and relies on version management with git. Page appearances are directed with YAML headers. For each page a PDF file is produced to allow regular print output. Index pages for navigation between pages are automatically created. category: Development Web homepage: https://github.com/andrewufrank/u4blog.git#readme bug-reports: https://github.com/andrewufrank/u4blog.git/issues author: Andrew Frank maintainer: Andrew U. Frank frank@geoinfo.tuwien.ac.at copyright: 2021 Andrew U. Frank license: GPL license-file: LICENSE build-type: Simple extra-source-files: changelog.md README.md

source-repository head type: git location: https://github.com/andrewufrank/u4blog.git subdir: daino

library exposed-modules: Foundational.CmdLineFlags Foundational.Filetypes4sites Foundational.MetaPage Foundational.SettingsPage Lib.CheckProcess Lib.IndexCollect Lib.IndexMake Lib.Templating ShakeBake.Bake ShakeBake.CmdLineArgs ShakeBake.ConvertFiles ShakeBake.ReadSettingFile ShakeBake.Shake2 ShakeBake.StartDainoProcess ShakeBake.Watch Wave.Docrep2panrep Wave.Md2doc Wave.Panrep2html Wave.Panrep2pdf other-modules: Paths_daino hs-source-dirs: src other-extensions: OverloadedStrings build-depends: ReplaceUmlaut , base >4.7 && <5 , data-default-class , deepseq , dir-traverse , filepath , pandoc , pandoc-sidenote , path , path-io , uniform-cmdLineArgs >=0.1.5.1 , uniform-http , uniform-json >=0.1.5.2 , uniform-latex2pdf >=0.1.5.2 , uniform-pandoc >=0.1.5.2 , uniform-shake , uniform-strings >=0.1.5.1 , uniform-watch , uniform-webserver , uniformBase >=0.1.5.1 , unix default-language: Haskell2010

executable daino main-is: daino.hs other-modules: Paths_daino hs-source-dirs: app other-extensions: OverloadedStrings build-depends: ReplaceUmlaut , base >4.7 && <5 , daino , data-default-class , deepseq , dir-traverse , filepath , pandoc , pandoc-sidenote , path , path-io , uniform-cmdLineArgs >=0.1.5.1 , uniform-http , uniform-json >=0.1.5.2 , uniform-latex2pdf >=0.1.5.2 , uniform-pandoc >=0.1.5.2 , uniform-shake , uniform-strings >=0.1.5.1 , uniform-watch , uniform-webserver , uniformBase >=0.1.5.1 , unix default-language: Haskell2010

tbidne commented 1 year ago

"Boot libraries" like bytestring are those that come bundled with a given version of GHC. They cannot be reinstalled (for now). Once you pick the version of GHC you are using, you are fixed to specific versions of all boot libraries. This wiki page has a matrix for GHC + boot library versions.

In your case, you are using GHC 9.2.5 which requires bytestring-0.11.3.1. This is what the text bytestring-0.11.3.1/installed-0.11.3.1 means (it is pre-installed for that GHC). Yet your freeze file specifies bytestring ==0.11.4.0, hence the former is rejected. Every other bytestring is rejected, again, because GHC 9.2.5 requires bytestring-0.11.3.1.

It looks like you generated the freeze file with GHC 9.2.7 (see ghc-boot-th), which instead requires bytestring-0.11.4.0, hence this incompatibility. Try upgrading your compiler to GHC 9.2.7.

andreabedini commented 1 year ago

I don't think this is the problem. The only "non upgradeable" packages are these.

Your package would be free to use a newer version of bytestring; as long as it doesn't depend, directly or indirectly, on a non-upgradeable package which also depends on bytestring: ghc, ghci and ghc-boot.

What is happening here is that cabal freeze can be a blunt tool sometimes. It's fixing all the dependencies to the point of tying you to the exact compiler version. As @tbidne notices, fixing ghc-boot-th to 9.2.7 would not work on any other compiler version. base is another package that often changes between GHC versions.

What you can do is to manually remove or comment out from cabal.project.freeze the following constraints. This will give you a plan that works on both 9.2.8 and 9.2.5.

  any.array ==0.5.4.0,
  any.base ==4.16.4.0,
  any.deepseq ==1.4.6.1,
  any.ghc-bignum ==1.2,
  any.ghc-boot-th ==9.2.7,
  any.ghc-prim ==0.8.0,
  any.integer-gmp ==1.1,
  any.mtl ==2.2.2,
  any.pretty ==1.1.3.6,
  any.rts ==1.0.2,
  any.stm ==2.5.0.2,
  any.template-haskell ==2.18.0.0,
  any.transformers ==0.5.6.2,

Of course using GHC 9.2.8 on both machines would be the best choice :joy:

tbidne commented 1 year ago

Ah, you are right @andreabedini. Thanks for the clarification!

andrewufrank commented 1 year ago

Thank you for your help! To use freeze seems to require a bit more knowledge about the working of cabal and ghc than I have.

Given the obvious strong dependencies on the version of GHC, I think it would be a good idea to include the ghc version information in the freeze file and produce a warning when a user tries to use a freeze file with a different version of GHC. It would help users with limited understanding (and save you questions like mine).

Noting the ghc version, which is essentially fixed for a freeze file (including fixing versions like the ones mentioned in the comment from @andreabedini) in the freeze file would document this dependency more visibly. It would make it easier to understand what freeze does and make it behavior a bit mor similar to the stack LTS behavior (which fixes the ghc version).

Thank you for help; I changed the second installation to the same ghc 9.27 and the compilation is successful!

hasufell commented 1 year ago

Generally "can install on a different machine" is not a property of cabal freeze. Because e.g. pkg-config files existing on the system are part of the solver run.

andrewufrank commented 1 year ago

Thank you for the clarifications on how freeze works; I understand now a few things better. I read some of the discussionon the drafted patch and think a "frozen-with-ghc" in an error message would have helped me to understand and resolve the issue quickly! @andreabedini Thank you for the draft!