Jivan
Jivan

Reputation: 23078

Stack: random dependency cycle(s) detected

The contents of stack.yaml is as follows:

resolver: lts-16.19

packages:
  - .

extra-deps:
  - text-1.2.4.0
  - random-1.2.0
  - git: https://github.com/LeventErkok/sbv.git # sbv
    commit: 4f4baa7b5970ef2ab9b322c6694bf9df6ccdbc4b
  - git: https://github.com/bos/aeson # aeson
    commit: 8579faf30e0f977425fbf330038fb1d5c2c34727
  - data-fix-0.3.0@sha256:058a266d1e658500e0ffb8babe68195b0ce06a081dcfc3814afc784b083fd9a5,1645
  - strict-0.4@sha256:1b50c7c9c636c3a1bbc7f8873b9be48f6ca0faca4df6eec6a014de6208fb1c0e,4200

While test has this section:

executable test
  hs-source-dirs:      src
  main-is:             Main.hs
  default-language:    Haskell2010
  build-depends:       text, random, sbv, aeson, base >= 4.7 && < 5

I added text and random because if I don't, I get the following errors when running stack ghci:

Could not load module ‘Data.Text’
Could not load module ‘System.Random’

But now, with these packages added as they are above, Stack complains about circular dependencies:

$ stack setup
$ stack ghci

Error: While constructing the build plan, the following exceptions were encountered:

In the dependencies for QuickCheck-2.13.2:
    random dependency cycle detected: random, splitmix, random, uuid-types, aeson, test
needed due to test-0.1.0.0 -> QuickCheck-2.13.2

In the dependencies for test-0.1.0.0:
    random dependency cycle detected: random, splitmix, random, uuid-types, aeson, test
needed since test is a build target.

Dependency cycle detected in packages:
    [random,splitmix,random,uuid-types,aeson,test]

In the dependencies for sbv-8.8.5:
    random dependency cycle detected: random, splitmix, random, uuid-types, aeson, test
needed due to test-0.1.0.0 -> sbv-8.8.5

In the dependencies for splitmix-0.0.5:
    random dependency cycle detected: random, splitmix, random, uuid-types, aeson, test
needed due to test-0.1.0.0 -> splitmix-0.0.5

Some different approaches to resolving this:


Error: Plan construction failed.

Based on the error messages it looks that there's a circular between splitmix, and random. I only asked for random therefore I'm not sure how to solve this problem.

Any way to fix this and make the imports work while avoiding this circular imports issue would be appreciated.

Upvotes: 3

Views: 614

Answers (1)

Li-yao Xia
Li-yao Xia

Reputation: 33464

The newest random is not compatible with the old version of splitmix in the lts-16.19 snapshot. Add a newer version of splitmix in extra-deps:

extra-deps:
- ...  # your other extra-deps
- splitmix-0.1.0.3

Upvotes: 4

Related Questions