Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency cycle error between Cabal-3.8.1.0 and Cabal-syntax-3.6.0.0 on Windows #6052

Closed
msakai opened this issue Feb 14, 2023 · 2 comments
Closed

Comments

@msakai
Copy link

msakai commented Feb 14, 2023

General summary/comments (optional)

I have a script to process cabal files and when I ran the script with stack runhaskell --package Cabal on Windows, I encountered a dependency cycle error between Cabal-3.8.1.0 and Cabal-syntax-3.6.0.0.

Steps to reproduce

echo "import Distribution.PackageDescription.Parsec" > test.hs
echo "main = return ()" >> test.hs
stack --verbose --resolver lts-20.11 runhaskell --package Cabal test.hs

Expected

I expect that stack uses Cabal-3.6.3.0 from lts-20.11 and that test.hs runs successfully.

Actual

Stack tried to use Cabal-3.8.1.0 and It failed with a dependency cycle error of [Cabal,Cabal-syntax,Cabal].

stack --verbose --resolver lts-20.11 runhaskell --package Cabal test.hs
Version 2.9.3, Git revision 6cf638947a863f49857f9cfbf72a38a48b183e7e x86_64 hpack-0.35.1
2023-02-14 08:33:00.880518: [debug] Checking for project config at: C:\Users\sakai\stack.yaml
2023-02-14 08:33:00.881515: [debug] Checking for project config at: C:\Users\stack.yaml
2023-02-14 08:33:00.881515: [debug] Checking for project config at: C:\stack.yaml
2023-02-14 08:33:00.881515: [debug] No project config file found, using defaults.
2023-02-14 08:33:00.888527: [debug] (SQL) SELECT COUNT(*) FROM "last_performed" WHERE ("action"=?) AND ("timestamp">=?); [PersistInt64 1,PersistUTCTime 2023-02-12 23:33:00.8875273 UTC]
2023-02-14 08:33:00.888527: [debug] Using resolver: lts-20.11 specified on command line
2023-02-14 08:33:00.888527: [debug] Run from outside a project, using implicit global project config
2023-02-14 08:33:00.899495: [debug] Using package location completions from a lock file
2023-02-14 08:33:01.072906: [debug] Prefetching git repos: []
2023-02-14 08:33:01.072906: [debug] []
2023-02-14 08:33:01.075899: [debug] Asking for a supported GHC version
2023-02-14 08:33:01.076896: [debug] Installed tools:
 - msys2-20150512
 - ghc-9.4.4
 - ghc-9.2.5
 - ghc-9.0.2
 - ghc-8.8.4
 - ghc-8.10.7
2023-02-14 08:33:01.076896: [debug] Potential GHC builds: standard
2023-02-14 08:33:01.076896: [debug] Found already installed GHC builds: standard
2023-02-14 08:33:01.077903: [debug] (SQL) SELECT "id","actual_version","arch","ghc_path","ghc_size","ghc_modified","ghc_pkg_path","runghc_path","haddock_path","cabal_version","global_db","global_db_cache_size","global_db_cache_modified","info","global_dump" FROM "compiler_cache" WHERE "ghc_path"=?; [PersistText "C:\\Users\\sakai\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-9.2.5\\bin\\ghc-9.2.5.exe"]
2023-02-14 08:33:01.111775: [debug] Loaded compiler information from cache
2023-02-14 08:33:01.111775: [debug] Asking for a supported GHC version
2023-02-14 08:33:01.111775: [debug] Resolving package entries
2023-02-14 08:33:01.111775: [debug] Parsing the targets
2023-02-14 08:33:01.123742: [debug] Checking flags
2023-02-14 08:33:01.123742: [debug] SourceMap constructed
2023-02-14 08:33:01.128729: [debug] Starting to execute command inside EnvConfig
2023-02-14 08:33:01.129727: [debug] Finding out which packages are already installed
2023-02-14 08:33:01.130724: [debug] Run process: C:\Users\sakai\AppData\Local\Programs\stack\x86_64-windows\ghc-9.2.5\bin\ghc-pkg-9.2.5.exe --global --no-user-package-db dump --expand-pkgroot
2023-02-14 08:33:01.184976: [debug] Process finished in 55ms: C:\Users\sakai\AppData\Local\Programs\stack\x86_64-windows\ghc-9.2.5\bin\ghc-pkg-9.2.5.exe --global --no-user-package-db dump --expand-pkgroot
2023-02-14 08:33:01.200964: [debug] Ignoring package Cabal due to wanting version 3.8.1.0 instead of 3.6.3.0
2023-02-14 08:33:01.201961: [debug] Run process: C:\Users\sakai\AppData\Local\Programs\stack\x86_64-windows\ghc-9.2.5\bin\ghc-pkg-9.2.5.exe --user --no-user-package-db --package-db C:\sr\snapshots\1d8e8bee\pkgdb dump --expand-pkgroot
2023-02-14 08:33:01.241182: [debug] Process finished in 39ms: C:\Users\sakai\AppData\Local\Programs\stack\x86_64-windows\ghc-9.2.5\bin\ghc-pkg-9.2.5.exe --user --no-user-package-db --package-db C:\sr\snapshots\1d8e8bee\pkgdb dump --expand-pkgroot
2023-02-14 08:33:01.241182: [debug] Run process: C:\Users\sakai\AppData\Local\Programs\stack\x86_64-windows\ghc-9.2.5\bin\ghc-pkg-9.2.5.exe --user --no-user-package-db --package-db C:\sr\global-project\.stack-work\install\26139240\pkgdb dump --expand-pkgroot
2023-02-14 08:33:01.279997: [debug] Process finished in 39ms: C:\Users\sakai\AppData\Local\Programs\stack\x86_64-windows\ghc-9.2.5\bin\ghc-pkg-9.2.5.exe --user --no-user-package-db --package-db C:\sr\global-project\.stack-work\install\26139240\pkgdb dump --expand-pkgroot
2023-02-14 08:33:01.280996: [debug] Constructing the build plan
2023-02-14 08:33:01.281993: [debug] Parsing cabal file for Cabal (from Hackage)
2023-02-14 08:33:01.281993: [debug] Got blob from Pantry database for Cabal-3.8.1.0@sha256:58d16c6779bb284b46dee648746da839da94925b1137fd2dbffd172fdb2a50ad,12593
2023-02-14 08:33:01.287976: [debug] Parsing cabal file for Cabal-syntax (from Hackage)
2023-02-14 08:33:01.288974: [debug] Got blob from Pantry database for Cabal-syntax-3.6.0.0@sha256:037d70bb091c49f68726dde920f6a003b646835a86cdcb5b5ad58ad9af3207d9,1567
2023-02-14 08:33:01.302937: [debug] Checking for project config at: C:\Users\sakai\stack.yaml
2023-02-14 08:33:01.303934: [debug] Checking for project config at: C:\Users\stack.yaml
2023-02-14 08:33:01.303934: [debug] Checking for project config at: C:\stack.yaml
2023-02-14 08:33:01.303934: [debug] No project config file found, using defaults.
2023-02-14 08:33:01.307950: [debug] (SQL) SELECT COUNT(*) FROM "last_performed" WHERE ("action"=?) AND ("timestamp">=?); [PersistInt64 1,PersistUTCTime 2023-02-12 23:33:01.3069529 UTC]
2023-02-14 08:33:01.307950: [error]
Error: [S-4804]
       Stack failed to construct a build plan.

       While constructing the build plan, Stack encountered the following errors:

       Dependency cycle detected in packages:
           [Cabal,Cabal-syntax,Cabal]

       In the dependencies for Cabal-syntax-3.6.0.0:
           Cabal dependency cycle detected: Cabal, Cabal-syntax, Cabal
       needed due to Cabal-3.8.1.0 -> Cabal-syntax-3.6.0.0

I'm wondering why stack tried to combine Cabal-3.8.1.0 and Cabal-syntax-3.6.0.0 even though Cabal-3.6.3.0 is included in lts-20.11 and Cabal-3.8.1.0 requires Cabal-syntax >= 3.8 && < 3.9

The problem does not happen on x86_64-osx.

Also, the problem does not happen if I remove --package Cabal.

Stack version

stack --version
Version 2.9.3, Git revision 6cf638947a863f49857f9cfbf72a38a48b183e7e x86_64 hpack-0.35.1

Method of installation

  • Official binary, downloaded via haskellstack.org or from Stack's repository

Platform

x86_64-windows

@mpilgrem
Copy link
Member

mpilgrem commented Feb 15, 2023

@msakai, I think you get this result because:

  • Cabal (being a GHC boot library) is not (directly) in the Stackage LTS 20.11 snapshot (rather, it is in the global hints for GHC 9.2.5), so requesting --package Cabal specifies the most recent version on Hackage (being Cabal-3.8.1.0); and
  • Cabal depends on Cabal-syntax and Cabal-syntax-3.6.0.0 is in the LTS 20.11 snapshot; and
  • Cabal-3.8.1.0 and Cabal-syntax-3.6.0.0 are incompatible.

So, I think you want either stack --resolver lts-20.11 runhaskell --package Cabal --package Cabal-syntax-3.8.1.0 test.hs or stack --resolver lts-20.11 runhaskell --package Cabal-3.6.0.0 test.hs.

It is the same if you command stack --resolver lts-20.11 build Cabal --dry-run. You get:

Error: [S-4804]
       Stack failed to construct a build plan.

       While constructing the build plan, Stack encountered the following errors:

       Dependency cycle detected in packages:
           [Cabal,Cabal-syntax,Cabal]

       In the dependencies for Cabal-syntax-3.6.0.0:
           Cabal dependency cycle detected: Cabal, Cabal-syntax, Cabal
       needed due to Cabal-3.8.1.0 -> Cabal-syntax-3.6.0.0

At the very least, I think it needs to be documented that GHC boot libraries are not part of Stackage snapshots.

(EDIT: In the original version of this post, I mistakenly thought --package could be used with a white-space delimited list of packages.)

@mpilgrem
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants