除非以管理员身份运行,否则堆栈ghci无法加载pthread [英] stack ghci can't load pthread unless running as Administrator

查看:66
本文介绍了除非以管理员身份运行,否则堆栈ghci无法加载pthread的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在一个全新的项目上运行 stack ghci 时,它无法加载:

  $堆栈新的repro简单下载模板"simple"以在repro \中创建项目"repro" ... 

(省略了其他输出以使问题更易于理解.)

  $ cd repro/$堆栈ghci使用主模块:1.用主文件打包C:\ Users \ mark \ Desktop \ repro \ src \ Main.hs的`repro'组件repro:exe:repro一次为"repro"构建所有可执行文件.成功构建所有这些文件后,将仅重建指定的可执行文件.复制配置(exe)配置repro-0.1.0.0 ...复制初始构建步骤(exe)使用以下软件包配置GHCi:reproGHCi,版本8.6.5:http://www.haskell.org/ghc/:?求助<命令行> ;:无法加载用户指定的.o/.so/.DLL(addDLL:pthread或依赖项未加载.(Win32错误5))尝试加载时:(动态)pthread搜索的其他目录:C:\\ Users \\ mark \\ AppData \\ Local \\ Programs \\ stack \\ x86_64-windows \\ msys2-20180531 \\ mingw64 \\ libC:\\ Users \\ mark \\ AppData \\ Local \\ Programs \\ stack \\ x86_64-windows \\ msys2-20180531 \\ mingw64 \\ binC://用户//mark//AppData//本地//程序//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:/用户/标记/AppData/本地/程序/堆栈/x86_64-windows/ghc-8.6.5/mingw/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/C:/用户/标记/AppData/本地/程序/堆栈/x86_64-windows/ghc-8.6.5/mingw/bin/../lib/gcc/C:/用户/标记/AppData/本地/程序/堆栈/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:/用户/标记/AppData/本地/程序/堆栈/x86_64-windows/ghc-8.6.5/mingw/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../lib/C:/用户/标记/AppData/本地/程序/堆栈/x86_64-windows/ghc-8.6.5/mingw/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib/C:/用户/标记/AppData/本地/程序/堆栈/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使用主模块:1.用主文件打包C:\ Users \ mark \ Desktop \ repro \ src \ Main.hs的`repro'组件repro:exe:repro一次为"repro"构建所有可执行文件.成功构建所有这些文件后,将仅重建指定的可执行文件.复制初始构建步骤(exe)使用以下软件包配置GHCi:reproGHCi,版本8.6.5:http://www.haskell.org/ghc/:?求助[1/1]编译Main(C:\ Users \ mark \ Desktop \ repro \ src \ Main.hs,已解释)好的,已加载一个模块.从C:\\ Users \\ mark \\ AppData \\ Local \\ Temp \\ haskell-stack-ghci \\ 2524149e \\ ghci-script加载的GHCi配置* Main> 

我已经在Windows上使用Stack多年了,这是我第一次必须以管理员身份运行,这确实让我感到困扰.可能是什么问题,我该如何解决?

FWIW,这是堆栈版本:

  $ stack --version版本2.1.3,Git修订版0fa51b9925decd937e4a993ad90cb686f88fa282(7739次提交)x86_64 hpack-0.31.2 

此版本与未出现问题的另一台计算机上的版本相同.

这里的示例是从运行 Git Bash 复制而来的,但是如果我使用 cmd ,问题也会相同.

解决方案

感谢Fyodor Soikin,我能够找到问题所在.

摘要

提供您的用户帐户阅读并添加对 pthread.dll 执行权限.

详细信息

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

经过仔细检查,结果发现其他计算机根本没有 pthread.dll 文件.

尽管它确实有很多 pthread.h 副本,但我想这足以使 Stack 构建代码.

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

我给了本地 Users Read&执行文件的权限,之后一切似乎都可以像以前在其他计算机上一样进行.

When I run stack ghci on a brand-new project, it fails to load:

$ stack new repro simple
Downloading template "simple" to create project "repro" in repro\ ...

(Additional output omitted to make the question more readable.)

$ 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

This is on Windows 10 (x64). I have another machine with a similar OS configuration and stack version, and on that machine, I have no problems. This seems to be an environment issue, but I can't figure out what it is.

I'm running from Git Bash, and if I run it as Administrator, it works:

$ 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>

I've been working with Stack for years on Windows, and this is the first time I've have to run as Administrator, and it really bothers me. What could be the issue, and how do I address it?

FWIW, this is the Stack version:

$ stack --version
Version 2.1.3, Git revision 0fa51b9925decd937e4a993ad90cb686f88fa282 (7739 commits) x86_64 hpack-0.31.2

This is the same version as I have on the other machine where the issue doesn't appear.

Examples here are copied from running Git Bash, but the issue is the same if I use cmd.

解决方案

Thanks to Fyodor Soikin, I was able to track down the issue.

Summary

Give your user account Read & execute permissions to pthread.dll.

Details

I didn't understand why this new machine of mine exhibited this problem while another machine with the same OS and basically the same setup didn't have any problems.

On close inspection, it turned out that that other machine didn't have a pthread.dll file at all.

It did have quite a few copies of pthread.h, though, and I suppose that this was enough to enable Stack to build the code.

The new machine had pthread.dll in a few places, including a subdirectory of C:\Windows\System32\DriverStore, which implies to me that this file originally arrived via a driver that the new machine uses, but the old machine didn't have. It also has a copy of pthread.dll in C:\Windows\System32, but this file was extraordinarily locked down. My own user account didn't have Read or Execute rights to the file, but I could view and change the permissions in Administrator mode.

I gave the local Users group Read & execute rights to the file, after which everything seems to work as it's previously done on my other machines.

这篇关于除非以管理员身份运行,否则堆栈ghci无法加载pthread的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆