I've built a simple app with these dependencies:
[dependencies]
core-foundation = { version = "0.9", features = ["with-chrono"] }
With cargo 1.62.1 (a748cf5a3 2022-06-08). My platform is a Macbook Air M1 (the target might matter, not sure).
And I'm getting this error:
error: cyclic package dependency: package `chrono v0.4.21` depends on itself. Cycle:
package `chrono v0.4.21`
... which satisfies dependency `chrono = "^0.4"` of package `core-foundation v0.9.3`
... which satisfies dependency `core-foundation = "^0.9"` of package `iana-time-zone v0.1.42`
... which satisfies dependency `iana-time-zone = "^0.1.41"` of package `chrono v0.4.21`
If I clone core-foundation and build it myself using cargo build --features="with-chrono", I'm not getting any error.
Any idea how to investigate this issue?
Unfortunately, there isn't much you can do if the cyclic dependency occurs with crates you don't control. You could attempt to "fix" one of the crates by cloning and modifying it to avoid a problematic dependency and override your dependencies with the fixed version.
Your best bet is to notify the maintainers of the crates involved. If the issue only arose recently, you can try locking your dependencies to an earlier version as a workaround.
This particular issue seems to be resolved already. It likely happened when chrono added iana-time-zone as a dependency in version 0.4.21. However, the fix was for iana-time-zone to change its dependency from core-foundation to core-foundation-sys in version 0.1.45 to break the cycle.
I am working on my first major Haskell application, and want to add mockery to create disposable test WAI threads. Importing mockery and running stack test resulted in the compiler error:
Failed to load interface for ‘Test.Mockery.Directory’
It is a member of the hidden package ‘mockery-0.3.5’.
Perhaps you need to add ‘mockery’ to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
So, I added mockery to my cabal file under test dependencies. However, when I run stack build or stack test mockery is automatically removed from the cabal file.
I have also tried listing mockery-0.3.5 under extra-deps in the stack.yaml file. This unsurprisingly didn't work, since mockery is part of my lts, and extra deps is for packages outside of lts.
How can I get stack to recognize that mockery should be included as a dependency to to project?
Here is my stack.yaml:
flags: {}
ghc-options:
! '*': -Wall
packages:
- .
extra-deps: [
]
resolver: lts-9.5
I'm using stack version 1.5.1
I imagine this is a stupid build issue and look forward to confronting my obvious oversight.
In stack.yaml you declare the Stackage LTS version, a curated list of hackage dependencies that you want to depend on. You can also depend on local packages and packages in git that are not in Hackage. You may also change the versions of the packages in LTS as long as they respect the constraints of the other dependencies.
package.yaml is the build file. Any packages you want to import directly in your Haskell code must be declared in here as dependencies, even if they are explicitly declared in the stack.yaml.
Finally, when you see It is a member of the hidden package, that means that one of your dependencies is using that package, but it is not declared as a dependency in your build file.
I've tried stack clean, and also removing .stack-work.
But still, every time I run build it unregisters 5 (the same) packages.
stack build --dry-run tells me the list, but not any reason why.
I've also recently upgraded from 1.4.1
Also, if it is not quite simple how to figure this out, I'd like to get back to using 1.4.1. Any simple way to downgrade haskell-stack to that version?
Edit 1
Downgrading to 1.4.0 didn't help. About 70 packages got unregistered and rebuilt, and after that I got into the same 5-unregister-loop.
So I thought, where else could have my local state be corrupted since ~yesterday? ~/.stack! So I've (re)moved my ~/.stack folder, and also .stack-work folder, thinking that if anything could have gone wrong it's in these two places, and now I am in an even worse of a rut. Now the constant unregister cycle includes 23 packages (some of them quite heavy) instead of just 5.
Would unregister locally:
cairo-0.13.3.1 (missing dependencies: gtk2hs-buildtools)
dump-0.3.0 (missing dependencies: haskell-src-meta, interpolatedstring-perl6)
entropy-0.3.7
ghcjs-dom-0.2.4.0 (missing dependencies: glib, gtk3, webkitgtk3)
gio-0.13.3.1 (missing dependencies: glib, gtk2hs-buildtools)
glib-0.13.4.1 (missing dependencies: gtk2hs-buildtools)
gtk2hs-buildtools-0.13.2.2 (missing dependencies: happy)
gtk3-0.14.6 (missing dependencies: cairo, gio, glib, gtk2hs-buildtools, pango)
haskell-src-exts-1.17.1 (missing dependencies: happy)
haskell-src-meta-0.6.0.14 (missing dependencies: haskell-src-exts)
here-1.2.9 (missing dependencies: haskell-src-meta)
hs-di-0.4.0 (missing dependencies: haskell-src-meta, interpolate, interpolatedstring-perl6)
interpolate-0.1.0 (missing dependencies: haskell-src-meta)
interpolatedstring-perl6-1.0.0 (missing dependencies: haskell-src-meta)
pango-0.13.3.1 (missing dependencies: cairo, glib, gtk2hs-buildtools)
reflex-0.5.0 (missing dependencies: haskell-src-exts, haskell-src-meta)
reflex-dom-0.4 (missing dependencies: ghcjs-dom, glib, gtk3, reflex, webkitgtk3, webkitgtk3-javascriptcore)
threepenny-gui-0.7.1.0
uuid-1.3.13
webkitgtk3-0.14.2.1 (missing dependencies: cairo, glib, gtk2hs-buildtools, gtk3, pango)
webkitgtk3-javascriptcore-0.13.2.0 (missing dependencies: glib, gtk2hs-buildtools, gtk3, webkitgtk3)
websockets-0.9.8.2
websockets-snap-0.10.0.0
#user2407038, what kind of information might help to start diagnosing this? Is the above helpful to begin with? Under what circumstances can ever such an unregister-loop arise?
I have one more idea that I could try: this particular project depends on a few local packages, and afaik their .stack-work folder may play a role in this. So maybe I could (re)move those as well.
Any more ideas should the above one fail?
Long story short: changing resolver: lts-7.19 to resolver: lts-7.24 in stack.yaml seems to have fixed the error for me.
I have some guesses and hunches what may have gone wrong in the background, but I am not entirely sure.
I got a clue from the --dry-run flag that some of the missing packages it reports are build-time haskell package dependencies, like alex, happy, etc...
So maybe the older lts didn't install those correctly? If someone is more knowledgeable on the subject, I'd love to hear more.
And I'm also sad that this incident has destroyed some of my trust in stack's promise of reproducible builds, as a (AFAIK purported-to-be-safe) stack upgrade (and even with subsequent downgrade) suddenly left one of my projects un-buildable for days.
And at any rate, I'd love if
stack would warn and ask me before it makes destructive changes on my system, especially if it results in hours of recompilation. (Which actually meant days of head-scratching in my case since any idea I tried I had to wait quite a bit of time in-between.)
It could employ a similar build store as nix, whereas even if I change some configuration, I can switch back to the previous working configuration readily.
As a partial solution, I found that I can
stack upgrade --binary-version 1.4.0
Which readily performs the downgrade:
Current Stack version: 1.5.1, available download version: 1.4.0
Forcing binary upgrade
Querying for archive location for platform: linux-x86_64-static
Downloading from: https://github.com/commercialhaskell/stack/releases/download/v1.4.0/stack
-1.4.0-linux-x86_64-static.tar.gz
Download complete, testing executable
Version 1.4.0, Git revision e714f1dd3fade19496d91bd6a017e435a96a6bcd (4640 commits) x86_64
hpack-0.17.0
New stack executable available at /home/user/.local/bin/stack
It could have been the case the you were hitting this bug: Better calculation of SourceMap, but again not enough information to tell for sure. Considering that this issue will get fixed soon, it shouldn't be a problem anymore, but if anyone is looking for a work around custom snapshots seem to work pretty well.
The gist of custom snapshots is by moving all immutable packages from extra-deps into a custom snapshot will prevent stack from recalculating dependencies for these packages.
I want to use Yesod web framework with yesod-auth-oauth, but I encountered a dependency problem while cabal-dev install:
/Users/kenta/myapp/oryza% cabal-dev install
Resolving dependencies...
cabal: cannot configure yesod-platform-1.0.2. It requires data-default ==0.4.0
For the dependency on data-default ==0.4.0 there are these packages:
data-default-0.4.0. However none of them are available.
data-default-0.4.0 was excluded because authenticate-oauth-1.3.0 requires
data-default ==0.3.*
data-default-0.4.0 was excluded because data-default-0.3.0 was selected
instead
data-default-0.4.0 was excluded because oryza-0.0.0 requires data-default
==0.3.*
I don't have any idea of what's wrong.
What I did is just inserting one line in Cabal file:
yesod-auth-oauth >= 1.0 && < 1.1
The default scaffolding works fine, which is created through yesod init.
The version information
yesod-core: 1.0.1
cabal-dev: 0.9.1 (build with Cabal 1.14.0)
cabal-install: 0.10.2
GHC: 7.0.4
OS: Mac OS X Lion
Thanks.
This looks like an overly restrictive upper bound in the authenticate-oauth package. It would be best to follow up directly with the maintainer of that package.
In general, these kinds of issues are a side-effect of following the Package Versioning Policy. Basically, it's a trade-off between having these "refuse to compile" annoyances and more insidious "can't compile" problems.
I don't remember for sure, but I think my change to the cabal file for yesod-auth-oauth fixes this.
Has anybody managed to get Yorgey et al's "unbound" library, for working with syntax with binding, to install with the latest GHC (7.0.3) and Haskell platform? Trying a cabal install unbound, I get the following:
Resolving dependencies...
cabal: cannot configure unbound-0.2.3. It requires base >=4.3 && <5
For the dependency on base >=4.3 && <5 there are these packages: base-4.3.0.0
and base-4.3.1.0. However none of them are available.
base-4.3.0.0 was excluded because of the top level dependency base -any
base-4.3.1.0 was excluded because of the top level dependency base -any
Anybody know a solution/work around, or what may be happening here?
Just to close this one:
The "unbound" library works fine with the 2011 Haskell Platform, and indeed, builds without warnings.
The OP had multiple (older) versions of GHC in his path, leading to build errors, since the package relies on GHC 7. Ensuring you have exactly the Haskell Platform environment is the solution.
As a note, we should write a script that checks the sanity of a given Haskell environment, to catch errors like this.