无法在 VSCode 中编译第一个 Haskell 程序

问题描述 投票:0回答:2

我刚刚在 Windows 中安装了 Stack GHCI 和 Visual Studio Code。我试图构建并运行第一个简单的 Haskell putStrln 程序,但编译失败。 在 VS Code 终端中,我输入:

PS C:\Users\rmili\Documents> stack new TryHaskell
并创建了一个新文件夹“TryHaskell”,其中包含自动创建的文件“Lib.hs”和“Main.hs”

我尝试构建并运行 hs 文件。但我遇到了以下错误:

  1. 在新终端中,输入
    PS C:\Users\rmili\Documents\TryHaskell> stack build
    后,会出现以下错误:
    Error Messages:
         "'C:\Users\rmili\AppData\Local\Programs\stack\x86_64-windows\ghc-8.8.4\bin\ghc-pkg.exe'
    exited with an error:
    ghc-pkg.exe: hLock: permission denied (Access is denied.)
    )"
  1. Main.hs 和 Lib.hs 的顶部,
    module Main where
    module Lib
    行下面都有卷线,并带有错误消息:
    readCreateProcess: stack "exec" "ghc" "--" "-rtsopts=ignore" "-outputdir" "C:\\Users\\rmili\\AppData\\Local\\Temp\\hie-bios-98c9848bfed41b00" "-o" "C:\\Users\\rmili\\AppData\\Local\\hie-bios\\wrapper-4da94d68375fab32d2147da1837e9611.exe" "C:\\Users\\rmili\\AppData\\Local\\hie-bios\\wrapper-4da94d68375fab32d2147da1837e9611.hs" (exit 1): failedcompiler
    Peek Problem (Alt+F8)
    No quick fixes available

我的GHCI目录看起来不错,如下图: GHCI Directory

更新:看来防病毒软件对我来说是个问题,因为每当我尝试构建新的 hs 文件时,诺顿都会弹出一个窗口,说数据保护程序已阻止 Haskell 服务器的操作。在我要求诺顿专门排除此类操作后,我可以成功编译并运行我的 hs 文件。

但是,问题是“module Main where”和“module Lib”下的卷线仍然存在。如何删除上面第 2) 点所示的卷曲线及其相关错误消息?

haskell compilation haskell-stack ghci
2个回答
1
投票

欢迎来到哈斯克尔!

不幸的是,Windows 上的 Haskell 似乎存在各种“权限被拒绝”的错误。 (https://gitlab.haskell.org/ghc/ghc/-/issues/2924)。我没有直接的解决方法建议,除了确保所有软件都是最新的,尝试不同的配置,并尝试直接使用

ghc
进行构建,而不使用
stack

其他要尝试的事情包括确保您以管理员身份运行,并禁用防病毒软件。


0
投票

以管理员身份运行对我有用。与我的防病毒软件无关。

© www.soinside.com 2019 - 2024. All rights reserved.