当我在一个全新的项目上运行stack ghci
时,它无法加载:
$ stack new repro simple
Downloading template "simple" to create project "repro" in repro\ ...
(省略了其他输出,以使问题更易读。)
$ cd repro/
$ stack ghci
Using main module: 1. Package `repro' component repro:exe:repro with main-is file: C:\Users\mark\Desktop\repro\src\Main.hs
Building all executables for `repro' once. After a successful build of all of them, only specified executables will be rebuilt.
repro> configure (exe)
Configuring repro-0.1.0.0...
repro> initial-build-steps (exe)
Configuring GHCi with the following packages: repro
GHCi, version 8.6.5: http://www.haskell.org/ghc/ :? for help
<command line>: user specified .o/.so/.DLL could not be loaded (addDLL: pthread or dependencies not loaded. (Win32 error 5))
Whilst trying to load: (dynamic) pthread
Additional directories searched: C:\\Users\\mark\\AppData\\Local\\Programs\\stack\\x86_64-windows\\msys2-20180531\\mingw64\\lib
C:\\Users\\mark\\AppData\\Local\\Programs\\stack\\x86_64-windows\\msys2-20180531\\mingw64\\bin
C://Users//mark//AppData//Local//Programs//stack//x86_64-windows//ghc-8.6.5//mingw//bin/
C://Users//mark//AppData//Local//Programs//stack//x86_64-windows//ghc-8.6.5//mingw//bin/../lib/
C://Users//mark//AppData//Local//Programs//stack//x86_64-windows//ghc-8.6.5//mingw//bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/
C:/Users/mark/AppData/Local/Programs/stack/x86_64-windows/ghc-8.6.5/mingw/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/
C:/Users/mark/AppData/Local/Programs/stack/x86_64-windows/ghc-8.6.5/mingw/bin/../lib/gcc/
C:/Users/mark/AppData/Local/Programs/stack/x86_64-windows/ghc-8.6.5/mingw/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib/../lib/
C:/Users/mark/AppData/Local/Programs/stack/x86_64-windows/ghc-8.6.5/mingw/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../lib/
C:/Users/mark/AppData/Local/Programs/stack/x86_64-windows/ghc-8.6.5/mingw/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib/
C:/Users/mark/AppData/Local/Programs/stack/x86_64-windows/ghc-8.6.5/mingw/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../
C:\Windows\system32
这是在Windows 10(x64)上。我有一台具有类似OS配置和堆栈版本的计算机,并且在该计算机上,我没有任何问题。这似乎是环境问题,但我不知道这是什么。
我正在从Git Bash运行,如果我以管理员身份运行它,则可以运行:
$ stack ghci
Using main module: 1. Package `repro' component repro:exe:repro with main-is file: C:\Users\mark\Desktop\repro\src\Main.hs
Building all executables for `repro' once. After a successful build of all of them, only specified executables will be rebuilt.
repro> initial-build-steps (exe)
Configuring GHCi with the following packages: repro
GHCi, version 8.6.5: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling Main ( C:\Users\mark\Desktop\repro\src\Main.hs, interpreted )
Ok, one module loaded.
Loaded GHCi configuration from C:\\Users\\mark\\AppData\\Local\\Temp\\haskell-stack-ghci\\2524149e\\ghci-script
*Main>
我已经在Windows上使用Stack多年了,这是我第一次必须以管理员身份运行,这确实使我感到困扰。可能是什么问题,我该如何解决?
FWIW,这是堆栈版本:
$ stack --version
Version 2.1.3, Git revision 0fa51b9925decd937e4a993ad90cb686f88fa282 (7739 commits) x86_64 hpack-0.31.2
该版本与未出现问题的另一台计算机上的版本相同。
这里的示例是从运行Git Bash复制而来的,但是如果我使用
cmd
,问题也会相同。 最佳答案
感谢Fyodor Soikin,我得以找到问题所在。
概括
将您的用户帐户Read & execute
权限授予pthread.dll
。
细节
我不明白为什么我的这台新机器出现此问题,而另一台具有相同操作系统和基本相同设置的机器却没有任何问题。
经过仔细检查,结果发现另一台机器根本没有pthread.dll
文件。
不过,它确实有很多pthread.h
副本,我想这足以使Stack生成代码。
新机器在几个地方都有pthread.dll
,其中包括C:\Windows\System32\DriverStore
的子目录,这对我而言意味着该文件最初是通过新机器使用的驱动程序到达的,而旧机器则没有。它还在pthread.dll
中有一个C:\Windows\System32
的副本,但是此文件异常锁定。我自己的用户帐户没有该文件的Read
或Execute
权限,但是我可以在管理员模式下查看和更改权限。
我授予了本地Users组Read & execute
对该文件的权限,此后,一切似乎都像以前在其他计算机上所做的那样正常工作。
关于haskell - 除非以管理员身份运行,否则堆栈ghci无法加载pthread,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58156569/