You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Stack新手构建并发网页抓取工具时的依赖配置问题

Fixing Stack Dependency Issues for Your Web Scraper

Hey there! Let’s work through these Stack dependency hurdles together—building a concurrent web scraper is a fun project, so let’s get those dependencies sorted out.

First: Fix the allow-newer Placement

You mentioned adding allow-newer: true under the executable section didn’t work—that makes sense! allow-newer is a global/package-level setting, not an executable-specific one. You have two better options:

  • Option 1: Add it to your stack.yaml (recommended)
    Open your project’s stack.yaml file and add this line at the top level:

    allow-newer: true
    

    This applies the setting to your entire project, which is more flexible than putting it in the cabal file.

  • Option 2: Add it to the top of my-project.cabal
    If you prefer keeping it in the cabal file, place it before the executable block:

    allow-newer: true
    
    executable my-project
      ...
    

Second: Correct Your Dependency Syntax

Writing http == * triggers a parsing error because Cabal doesn’t allow unconstrained == wildcards. Instead, use one of these approaches for your build-depends section in my-project.cabal:

  • Allow any compatible version (simplest for beginners):

    build-depends:
      base >= 4.14 && < 5,
      hxt,
      url,
      http,
      maybet
    

    Stack will automatically pick the version of http that’s compatible with your resolver.

  • Specify a minimum version if you need features from a newer release:

    build-depends:
      base >= 4.14 && < 5,
      hxt,
      url,
      http >= 4000.3.9,
      maybet
    

Third: Resolve the "http 4000.3.9 Not Found" Error

When you specified http == 4000.3.9, Stack complained because that version isn’t included in your current resolver (the set of package versions Stack uses by default). Here’s how to fix this:

  1. Check your current resolver by running:
    stack resolver
    
  2. See which http versions are available in your resolver:
    stack exec ghc-pkg list http
    
  3. If you really need 4000.3.9, add it as an extra-dep in stack.yaml:
    extra-deps:
      - http-4000.3.9
    
    This tells Stack to fetch and use that specific version even if it’s not in the resolver.

Alternatively, you could switch to a resolver that includes http-4000.3.9, but using extra-deps is usually easier for one-off package version overrides.

I remember tripping over these exact dependency issues when I first started with Stack—once you get the hang of resolvers and extra-deps, it gets way smoother. Good luck with your web scraper!

内容的提问来源于stack exchange,提问作者Mark Karavan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 03:30:12