Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows msys2: pacman reports PGP signature errors. #5567

Closed
PaulJohnson opened this issue Jun 21, 2021 · 13 comments
Closed

Windows msys2: pacman reports PGP signature errors. #5567

PaulJohnson opened this issue Jun 21, 2021 · 13 comments

Comments

@PaulJohnson
Copy link

General summary/comments (optional)

I'm trying to install the text-icu library. When I run stack install text-icu I get an error:

* Missing (or bad) C libraries: icuuc, icuin, icudt

It suggests installing the icu development package. But when I try to say stack exec -- pacman -S icu-devel I get PGP signature errors.

Steps to reproduce

stack exec -- pacman -S icu-devel

Expected

Latest icu-devel packages installed.

Actual

resolving dependencies...
looking for conflicting packages...

Packages (2) icu-68.2-1  icu-devel-68.2-1

Total Download Size:    1.17 MiB
Total Installed Size:  57.45 MiB
Net Upgrade Size:      25.99 MiB

:: Proceed with installation? [Y/n] y
:: Retrieving packages...
 icu-devel-68.2-1-x86_64                                                1197.3 KiB  2.77 MiB/s 00:00 [###########################################################] 100%
(2/2) checking keys in keyring                                                                       [###########################################################] 100%
(2/2) checking package integrity                                                                     [###########################################################] 100%
error: icu: signature from "David Macek <[email protected]>" is unknown trust
:: File /var/cache/pacman/pkg/icu-68.2-1-x86_64.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] n
error: icu-devel: signature from "David Macek <[email protected]>" is unknown trust
:: File /var/cache/pacman/pkg/icu-devel-68.2-1-x86_64.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] n
error: failed to commit transaction (invalid or corrupted package (PGP signature))
Errors occurred, no packages were upgraded.

Stack version

$ stack --version
Version 2.7.1, Git revision 8afe0c2932716b0441cf4440d6942c59568b6b19 x86_64 hpack-0.34.4

Method of installation

  • Official binary, downloaded from stackage.org or fpcomplete's package repository
@ce-dot
Copy link

ce-dot commented Jun 21, 2021

Workaround: stack exec -- pacman -Sy msys2-keyring

The packaged msys2 is almost a year old now; so is pacman's trustdb.

@mpilgrem
Copy link
Member

Do any of the following assist?

  1. The Stack-supplied MSYS2 (if an existing one is absent) has recently been updated to the latest version 20220503. See msys2 dependency updating #5595 (comment)

  2. Noting the references to signature from "David Macek <[email protected]>" is unknown trust, I had that problem in the past when updating the Stack-supplied MSYS2 using MSYS2. I found this MSYS2 discussion to be of help in resolving the problem: error: XXXX : signature from "David macek <[email protected]>" is invalid msys2/MSYS2-packages#2343

@andreasabel
Copy link

andreasabel commented May 15, 2022

  1. The Stack-supplied MSYS2 (if an existing one is absent) has recently been updated to the latest version 20220503.

That could explain why my stack CI started failing under Windows: https://github.com/agda/agda/runs/6435596174?check_suite_focus=true

> <command line>: addDLL: icudt or dependencies not loaded. (Win32 error 126)   
> ghc.exe: addLibrarySearchPath: 
C:\Users\runneradmin\AppData\Local\Programs\stack\x86_64-windows\msys2-20210604\mingw64\lib (Win32 error 3): 
The system cannot find the path specified.

version 20220503

Can I get stack to tell me this version? Could be that I need to make this part of my cache keys...

@andreasabel
Copy link

Indeed, clearing the cache fixed my workflow: https://github.com/agda/agda/runs/6441965841?check_suite_focus=true

How can I get a robust cache key for a stack CI? Seems difficult if parts of stack are renewed without bumping the version number...

Atm, I have the key scheme OS-Stack-GHC-Yaml.lock (e.g. Windows-2.7.5-9.0.1-6c2bfc0ffd8aad4b0b1235aef7781dfad8790e9625165f2dee19f9919bba4397), but the MSYS update does not affect any of these components.

${{ runner.os }}-${{ env.STACK_VER }}-${{ env.GHC_VER }}-${{ hashFiles(format('stack-{0}.yaml.lock', env.GHC_VER)) }}

@mpilgrem
Copy link
Member

@andreasabel, on your question "Can I get stack to tell me the MSYS2 version?", the short answer is No. However, I have proposed a pull request that would add a command stack ls tools --filter msys2 which would do just that. See #5725.

@mpilgrem
Copy link
Member

@andreasabel, my knowledge of CI is limited, but what is the purpose of addLibrarySearchPath: C:\Users\runneradmin\AppData\Local\Programs\stack\x86_64-windows\msys2-20210604\mingw64\lib?

I had understood that, in the stack environment, stack 'automatically' knows that it should look in its stack-supplied MSYS2 \mingw64\lib folder for extra libraries?

@andreasabel
Copy link

my knowledge of CI is limited, but what is the purpose of addLibrarySearchPath: C:\Users\runneradmin\AppData\Local\Programs\stack\x86_64-windows\msys2-20210604\mingw64\lib?

This is not something that our CI is doing (check https://github.com/agda/agda/blob/d25dd477747155339afb9ad1159cffda0ef1111a/src/github/workflows/stack.yml), this must be something that stack is doing.

In short, the CI does the following steps:

  1. stack update
  2. stack build --dry-run, generating lock file
  3. restore .stack/ if stack version and lock file have not changed in comparison with last run of CI
  4. stack build

See also:

I had understood that, in the stack environment, stack 'automatically' knows that it should look in its stack-supplied MSYS2 \mingw64\lib folder for extra libraries?

Maybe something goes wrong if stack runs on a stale version of its root directory tree (.stack/) which is restored by the cache logic.
Maybe restoring the entirety of .stack/ is wrong? Is there some official advice how to set up caching of github CI builds when using stack? I was looking for a "blessed" stack action for CI but couldn't find anything...

@mpilgrem
Copy link
Member

@andreasabel, as I note above, my knowledge of CI is limited, but I don't understand how it can be caching-related.

 - with:
        path: ${{ steps.haskell-setup.outputs.stack-root }}
        key: |
          ${{ runner.os }}-stack-00-${{ env.STACK_VER }}-${{ hashFiles(format('stack-{0}.yaml.lock', env.GHC_VER)) }}
      uses: actions/cache@v2
      name: Cache dependencies
      id: cache

is caching the stack root directory - but, on Windows, that directory has nothing to do with the stack-supplied MSYS2. MSYS2 is a tool in the stack path --programs directory (which is outside the stack root directory). I think you can see in the log that the stack update --silent is triggering the download of MSYS2-20220503 into C:\Users\runneradmin\AppData\Local\Programs\stack\x86_64-windows\. I am still trying to workout what is causing the executables to think C:\Users\runneradmin\AppData\Local\Programs\stack\x86_64-windows\msys2-20210604\mingw64\lib is a relevant path.

@mpilgrem
Copy link
Member

Adding a link to this issue: https://gitlab.haskell.org/ghc/ghc/-/issues/14183 as it may provide an clue.

@andreasabel
Copy link

@mpilgrem wrote:

as I note above, my knowledge of CI is limited, but I don't understand how it can be caching-related.

Well, I imagine it like this:

  1. stack update downloads MSYS2-20220503 (https://github.com/agda/agda/runs/6435596174?check_suite_focus=true#step:7:23) and stores it or at least its configuration in .stack/ somewhere.
  2. An old cache build with MSYS2-20210604 is restored: https://github.com/agda/agda/runs/6435596174?check_suite_focus=true#step:7:23 ("Cache restored successfully").
    This overwrites .stack/ and annihilates the effects of stack update. Now stack is in an inconsistent state (but apparently has no routines to detect this). It is running on MSYS2-20220505 but its configuration is for MSYS-20210604.
  3. Running stack build in this inconsistent setup refers to paths that do not exist.

Does this sound plausible?
Is this true (not everything that is plausible is true...)?

@mpilgrem
Copy link
Member

I tried the following experiment, but it was a blind alley. I am using a version of stack built from the current master branch with GHC 9.0.2/Cabal-3.4.1.0. I created a simple project pkgTest (stack new pkgTest, which - today - uses lts-19.7) and added a dependency on acme-missiles-0.3, so that Main.hs became:

module Main where

import Lib
import Acme.Missiles

main :: IO ()
main = do
  someFunc
  launchMissiles

stack build creates a snapshot in the stack root (for me) at C:\sr\snapshots\00e41759 and I looked at that with stack exec -- ghc-pkg dump -f C:\sr\snapshots\00e41759\pkgdb, yielding:

name:                 acme-missiles
version:              0.3
visibility:           public
id:                   acme-missiles-0.3-KfaH05Ue1Cs8dT7ALloWDX
key:                  acme-missiles-0.3-KfaH05Ue1Cs8dT7ALloWDX
license:              LicenseRef-PublicDomain
maintainer:           [email protected]
author:               Joey Adams
synopsis:             Cause serious international side effects.
description:
    The highly effectful 'launchMissiles' action, as mentioned in /Beautiful concurrency/,
    Simon Peyton Jones, 2007.

category:             Acme
abi:                  b249e6658759461df541cdd5c2e3aeba
exposed:              True
exposed-modules:      Acme.Missiles Acme.Missiles.STM
import-dirs:
    C:\sr\snapshots\00e41759\lib\x86_64-windows-ghc-9.0.2\acme-missiles-0.3-KfaH05Ue1Cs8dT7ALloWDX

library-dirs:
    C:\sr\snapshots\00e41759\lib\x86_64-windows-ghc-9.0.2\acme-missiles-0.3-KfaH05Ue1Cs8dT7ALloWDX
    C:\Users\mike\AppData\Local\Programs\stack\x86_64-windows\msys2-20210604\mingw64\lib
    C:\Users\mike\AppData\Local\Programs\stack\x86_64-windows\msys2-20210604\mingw64\bin

dynamic-library-dirs:
    C:\sr\snapshots\00e41759\lib\x86_64-windows-ghc-9.0.2
    C:\Users\mike\AppData\Local\Programs\stack\x86_64-windows\msys2-20210604\mingw64\lib
    C:\Users\mike\AppData\Local\Programs\stack\x86_64-windows\msys2-20210604\mingw64\bin

data-dir:
    C:\sr\snapshots\00e41759\share\x86_64-windows-ghc-9.0.2\acme-missiles-0.3

hs-libraries:         HSacme-missiles-0.3-KfaH05Ue1Cs8dT7ALloWDX
include-dirs:
    C:\Users\mike\AppData\Local\Programs\stack\x86_64-windows\msys2-20210604\mingw64\include

depends:              base-4.15.1.0 stm-2.5.0.0
haddock-interfaces:
    C:\sr\snapshots\00e41759\doc\acme-missiles-0.3\acme-missiles.haddock

haddock-html:         C:\sr\snapshots\00e41759\doc\acme-missiles-0.3
pkgroot: "C:\\\\sr\\snapshots\\00e41759"

So, entries (a) in a file in my stack root (b) with paths to my existing stack-supplied MSYS2 (which is in msys2-20210604). Perhaps that was the cause of what @andreasabel was observing?

I investigated what happened if I disabled that MSYS2:

stack path --programs | cd
ren msys2-20210604 msys2-20210604.old
ren msys2-20210604.installed msys2-20210604.installed.old

Back in the project folder, stack build now (a) identified the missing MSYS2 and downloaded the latest MSYS2-20220503, and (b) yielded this (but no ghc.exe: addLibrarySearchPath errors reported):

pkgTest-0.1.0.0: unregistering (flags changed from ["--extra-include-dirs=C:\\Users\\mike\\AppData\\Local\\Programs\\stack\\x86_64-windows\\msys2-20210604\\mingw64\\include","--extra-lib-dirs=C:\\Users\\mike\\AppData\\Local\\Programs\\stack\\x86_64-windows\\msys2-20210604\\mingw64\\lib","--extra-lib-dirs=C:\\Users\\mike\\AppData\\Local\\Programs\\stack\\x86_64-windows\\msys2-20210604\\mingw64\\bin"] to ["--extra-include-dirs=C:\\Users\\mike\\AppData\\Local\\Programs\\stack\\x86_64-windows\\msys2-20220503\\mingw64\\include","--extra-lib-dirs=C:\\Users\\mike\\AppData\\Local\\Programs\\stack\\x86_64-windows\\msys2-20220503\\mingw64\\lib","--extra-lib-dirs=C:\\Users\\mike\\AppData\\Local\\Programs\\stack\\x86_64-windows\\msys2-20220503\\mingw64\\bin"])
pkgTest> configure (lib + exe)
Configuring pkgTest-0.1.0.0...
pkgTest> build (lib + exe)
Preprocessing library for pkgTest-0.1.0.0..
Building library for pkgTest-0.1.0.0..
[1 of 2] Compiling Lib [flags changed]
[2 of 2] Compiling Paths_pkgTest [flags changed]
Preprocessing executable 'pkgTest-exe' for pkgTest-0.1.0.0..
Building executable 'pkgTest-exe' for pkgTest-0.1.0.0..
[1 of 2] Compiling Main [flags changed]
[2 of 2] Compiling Paths_pkgTest [flags changed]
Linking .stack-work\dist\d53b6a14\build\pkgTest-exe\pkgTest-exe.exe ...
pkgTest> copy/register
Installing library in D:\Users\mike\Code\Haskell\pkgTest\.stack-work\install\a7a5ad27\lib\x86_64-windows-ghc-9.0.2\pkgTest-0.1.0.0-EYjhW8QjuAYDzydfO0o2wU
Installing executable pkgTest-exe in D:\Users\mike\Code\Haskell\pkgTest\.stack-work\install\a7a5ad27\bin
Registering library for pkgTest-0.1.0.0..

When I tried stack exec -- ghc-pkg dump -f C:\sr\snapshots\00e41759\pkgdb again, I had the same result as before - with the same paths to the old - now non-existent - C:\Users\mike\AppData\Local\Programs\stack\x86_64-windows\msys2-20210604. stack and ghc did not seem to be troubled by that.

If I deleted C:\sr\snapshots\00e41759, stack build recreated it - but this time with paths to the new C:\Users\mike\AppData\Local\Programs\stack\x86_64-windows\msys2-20220503

I tried the same thing but with a stack purge after disabling the existing MSYS2 and had the same result: stack and ghc did not seem troubled by C:\sr\snapshots\00e41759\pkgdb containing references to paths that no longer existed.

@mpilgrem
Copy link
Member

I am going to close this issue given the passage of time and because I think the original issue is no longer applicable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants