简体   繁体   中英

How to override hackage depedency in Stack with git branch

I am experiencing trouble with proto-lens library on GHC 8.10. It has not been supported. Team fixed issue, but didn't published update on Hackage and I am trying to pull the fix just from github tag.

I don't see any difference in building process after added following section to stack.yaml

allow-newer: true

extra-deps:
- github: google/proto-lens
  commit: 0bef8c2f3da645f068b8a26ac168c1da41608182
  subdirs: proto-lens

I guess I missed something. It is not clear for me how Stack sees this custom dependency. Where is association that it is source for proto-len? What if I made a typo in subdirs or url? So Stack could get something else and it could be even a correct Stack library, but not proto-lens.

Log of failing build

Warning: Unknown/unsupported 'ghc' version detected (Cabal 3.0.2.0 supports
'ghc' version < 8.10): /opt/ghc/8.10.1/bin/ghc is version 8.10.1
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: megaexample-0.4.2 (user goal)
[__1] trying: base-4.14.0.0/installed-4.1... (dependency of megaexample)
[__2] trying: opentelemetry-extra-0.4.2 (user goal)
[__3] next goal: proto-lens (dependency of opentelemetry-extra)
[__3] rejecting: proto-lens-0.6.0.0 (conflict:
base==4.14.0.0/installed-4.1..., proto-lens => base>=4.10 && <4.14)
[__3] rejecting: proto-lens-0.5.1.0, proto-lens-0.5.0.1, proto-lens-0.5.0.0,
proto-lens-0.4.0.1 (conflict: base==4.14.0.0/installed-4.1..., proto-lens =>

Another supplementary question: where is library version in Stack specified? Stack starts with 0.6, but there is no such literal in the source tree.

Link to source

Should I tweak cabal file also? The proto-lens library is referenced in cabal file.

executable eventlog-to-opentelemetry
  import: options
  main-is:    Main.hs
  hs-source-dirs: exe/eventlog-to-opentelemetry
  other-modules: Console, Json, Resource, Attribute, Spans
  build-depends:
    aeson,
    base,
    bytestring,
    clock,
    filepath,
    microlens,
    microlens-th,
    opentelemetry >= 0.4.0,
    opentelemetry-extra,
    opentelemetry-proto,
    optparse-applicative,
    proto-lens,
    text,
    unordered-containers,
  default-language: Haskell2010

Log of failing build

That error log is from cabal, not stack. cabal doesn't read stack.yaml , but cabal.project .

Here is the relevant part of cabal's documentation to specify remote dependencies: Cabal user manual

stack wouldn't try different versions of packages. The stack.yaml file specifies package versions upfront: every package is set to at most one specific version, either via extra-deps (where you specify individual packages explicitly) or resolver (which is a whole set of specific package versions, that you can browse on https://stackage.org ).

I guess I missed something. It is not clear for me how Stack sees this custom dependency. Where is association that it is source for proto-len? What if I made a typo in subdirs or url? So Stack could get something else and it could be even a correct Stack library, but not proto-lens.

It is indeed strange that doesn't seem to have an option to explicitly name the expected remote packages. This is an issue worth bringing up to stack maintainers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM