【问题标题】:Issue installing hlint on windows在 Windows 上安装 hlint 时出现问题
【发布时间】:2021-12-13 01:58:30
【问题描述】:

我正在尝试使用cabal install hlint 在 Windows 上安装 hlint,但出现以下错误:

   Preprocessing executable 'hlint' for hlint-1.8.50..
Building executable 'hlint' for hlint-1.8.50..

<no location info>: warning: [-Wmissing-home-modules]
    These modules are needed for compilation but not listed in your .cabal file's other-modules:
        Apply
        CmdLine
        HLint
        HSE.All
        HSE.Bracket
        HSE.Evaluate
        HSE.Match
        HSE.NameMatch
        HSE.Type
        HSE.Util
        Hint.All
        Hint.Bracket
        Hint.Duplicate
        Hint.Extensions
        Hint.Import
        Hint.Lambda
        Hint.List
        Hint.ListRec
        Hint.Match
        Hint.Monad
        Hint.Naming
        Hint.Pragma
        Hint.Structure
        Hint.Type
        Hint.Util
        Idea
        Language.Haskell.HLint
        Parallel
        Proof
        Report
        Settings
        Test
        Util
[ 1 of 35] Compiling HSE.Type         ( src\HSE\Type.hs, dist\build\hlint\hlint-tmp\HSE\Type.o )

src\HSE\Type.hs:6:1: error:
    Could not find module `Language.Haskell.Exts.Annotated'
    Perhaps you meant
      Language.Haskell.Exts.Syntax (from haskell-src-exts-1.23.1)
      Language.Haskell.Exts.Pretty (from haskell-src-exts-1.23.1)
      Language.Haskell.Exts.Build (from haskell-src-exts-1.23.1)
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
6 | import Language.Haskell.Exts.Annotated as Export hiding (parse, loc, parseFile, paren, Assoc(..))
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cabal.exe: Failed to build hlint-1.8.50. See the build log above for details.

Glorious Glasgow Haskell 编译系统,版本 9.2.1,hlint-1.8.50

【问题讨论】:

  • 什么版本的 ghc 和 hlint?
  • 你的 HLint 版本太旧了,建议升级一下。
  • 但是,请注意,截至今天,尚未发布的 HLint 版本可与 GHC 9.2.1 一起使用(因为它的一些依赖项尚未准备好 - 请参阅 github.com/ndmitchell/hlint/issues/1314
  • “升级”是什么意思?我什至没有安装它,这就是我从运行“cabal install hlint”中得到的消息。难道不应该拉取并安装最新版本吗?
  • cabal new-update 开头,然后是cabal new-install hlint。当然,您首先必须等到有一个可以与 GHC 9.2.1 干净编译的新 hlint 版本。同时,如果您想要 hlint,您唯一的选择是使用较旧的 GHC。

标签: haskell visual-studio-code cabal hlint


【解决方案1】:

根据 Neil Mitchell 的评论“没有发布的 HLint 版本可以与 GHC 9.2.1 一起使用(因为它的一些依赖项还没有准备好)”不可能在 GHC 9.2.1 上运行 HLint,默认情况下随 Chocolatey 和 Haskell Platform for Windows 安装。

但是,我找到了解决方法。我为 Windows 安装了 GHCup:

Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;Invoke-Command -ScriptBlock ([ScriptBlock]::Create((Invoke-WebRequest https://www.haskell.org/ghcup/sh/bootstrap-haskell.ps1 -UseBasicParsing))) -ArgumentList $true

GHCup 安装 cabal 和 ghc 8.10.7,与 HLint 完美兼容。 为了安装 HLint,我跑了:

cabal update
cabal install hlint

之后,将新创建的 hlint 二进制文件的位置添加到 PATH。瞧:一切都像魅力一样!

【讨论】:

    猜你喜欢
    • 2014-07-23
    • 2021-05-29
    • 2020-01-22
    • 2016-04-25
    • 1970-01-01
    • 2023-03-29
    • 2021-06-21
    • 2020-10-03
    • 2012-02-26
    相关资源
    最近更新 更多