fjvallarino/monomer

Issue setting up environment on Windows (again)

Closed this issue · 9 comments

I tried setting the environment up on Windows, but I ran into the usual "signature from ... is unknown trust" error. Unfortunately, just removing stack directories/reinstalling stack wasn't enough, and it took me a while to get it to work. However, eventually, I was able to set it up using a complex series of commands.

(Based on msys2/MSYS2-packages#2343 (comment))

First, I updated the keyring like so:

stack exec -- pacman -Syu
stack exec -- pacman -S msys2-keyring

Next, I had to use pacman-key to reset the keystore. However, since pacman-key is a shell script, it can't be run directly with stack exec. Instead, you have to run

stack exec -- sh

and then run the commands to reset the keystore.

rm -r /etc/pacman.d/gnupg/
pacman-key --init
pacman-key --populate msys2
exit

(You might be able to run these commands with stack exec by running stack exec -- sh <command> for each command, but I just ran them directly in sh.

Finally, I upgraded all the packages using

stack exec -- pacman -Syuu

I then closed all instances of cmd just to be safe, and then started it again and tried running the various commands to install the packages...

stack exec -- pacman -S mingw-w64-x86_64-pkg-config
stack exec -- pacman -S mingw-w64-x86_64-SDL2
stack exec -- pacman -S mingw-w64-x86_64-freeglut
stack exec -- pacman -S mingw-w64-x86_64-glew

... and it worked.

Hi @Anteproperispomenon!

Thanks for the detailed solution! I'll update the documentation to reflect this.

Supposedly, the latest versions of MinGW fix this issue, but probably the version shipped with Stack is outdated. Crossing fingers that it will be updated at some point.

I setup monomer today on windows and ran into this same issue. I didn't use stack, only cabal install with cabal installed by ghcup. Running pacman -S msys2-keyring in an msys2 shell fixed the issue without needing the rest of the solution.

To share a few other points I noticed about building monomer with cabal, my ghcup-installed distribution of msys2 came with mingw-w64-x86_64-pkgconf already installed rather than mingw-w64-x86_64-pkg-config. This fedora link seems to suggest pkgconf is recommended.

I also had to build with cabal build --constraint "nanovg +stb_truetype", otherwise cabal would complain about missing freetype. Seems like the flag in cabal.project is not working for some reason.

Hi @jiangbowen0!

The Cabal issue you mentioned seems to be related to this: haskell/cabal#7787. I'm mainly a Stack user, and when I tested building with Cabal it probably succeeded because I had FreeType installed. At some point I need to add a Cabal specific section to document all these issues and possible solutions.

I'll add a note about msys2-keyring alone maybe fixing the issue, and a suggestion to try the rest otherwise.

Thanks for the pointer regarding pkgconf/pkg-config! I'll check if the msys included with stack supports that package.

Not sure if it's related, but I was having similar issues (pkgconf complaining) on Arch Linux until I downgraded to cabal 3.6.2.0. I'll also note that it wasn't just monomer that was affected for me, but rather any library that depended on system libraries being installed (such as gi-gtk).

@Aspidites thanks! I'll try in a clean VM to see what happens.

A nice catch all command to fix the windows issues could be:

pacman -S msys2-keyring mingw-w64-x86_64-pkg-config mingw-w64-x86_64-glew mingw-w64-x86_64-freeglut mingw-w64-x86_64-SDL2 mingw-w64-x86_64-freetype

in the mingw64 that is being used to build the project, this fixed the same issue for me; for some reason ghc will never look at Windows' true system PATH variable and this effects other haskell libraries like cuda-ffi..

This reddit article was also rather detailed in it's description of the same issue:
https://www.reddit.com/r/haskellquestions/comments/wnctum/trying_to_install_monomer_on_windows/

@MilesLitteral thank you very much for pointing this out! I'll update the docs to include this.

Just to be sure: do you use Cabal or was this needed with Stack too?

@fjvallarino my apologies on the late reply

this was needed with either; I tried to use Cabal first but encountered the bug then shifted over to Stack and encountered the same problem

The Windows setup documentation has been updated to reflect the discussion in this issue. Thanks for the input!

I'll close the issue now. Please re-open or create a new one if you feel something is missing. Thanks!