stack ghci除非以管理员身份运行,否则无法加载pthread

问题描述 投票:4回答:1

当我在一个新项目上运行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,也会出现同样的问题。

haskell haskell-stack
1个回答
0
投票

感谢Fyodor Soikin,我得以找到问题所在。

摘要

将您的用户帐户Read & execute权限授予pthread.dll

详细信息

我不明白为什么我的这台新机器出现此问题,而另一台具有相同操作系统和基本相同设置的机器却没有任何问题。

仔细检查后发现,另一台计算机根本没有pthread.dll文件

不过,它确实有很多pthread.h的副本,我想这足以使Stack生成代码。

新机器在某些地方有pthread.dll,包括C:\Windows\System32\DriverStore的子目录,这对我而言意味着该文件最初是通过新机器使用的驱动程序到达的,而旧机器则没有。它在pthread.dll中也具有C:\Windows\System32的副本,但是此文件异常锁定。我自己的用户帐户没有文件的ReadExecute权限,但是我可以在管理员模式下查看和更改权限。

我向文件的本地Users

Read & execute授予了权限,此后一切似乎都像以前在其他计算机上所做的一样工作。
© www.soinside.com 2019 - 2024. All rights reserved.