I'm trying to build my Yesod web app with GHC 9.0.1 via stack
resolver: nightly-2021-09-02
My application uses PostgreSQL database. There are custom persist fields in my code derived via derivePersistField. Build failing with following error message:
<command line>: dlopen(/Users/arthurfayzrakhmanov/.stack/snapshots/x86_64-osx/b9ed0f8360016ada5efeb53015219761394cfd2d563da5d48a402d192c951f0a/9.0.1/lib/x86_64-osx-ghc-9.0.1/libHSpostgresql-libpq-0.9.4.3-4UpE2VczKgl8p7NC0fd3Q8-ghc9.0.1.dylib, 5): Symbol not found: _PQclear
Referenced from: /Users/arthurfayzrakhmanov/.stack/snapshots/x86_64-osx/b9ed0f8360016ada5efeb53015219761394cfd2d563da5d48a402d192c951f0a/9.0.1/lib/x86_64-osx-ghc-9.0.1/libHSpostgresql-libpq-0.9.4.3-4UpE2VczKgl8p7NC0fd3Q8-ghc9.0.1.dylib
Expected in: flat namespace
in /Users/arthurfayzrakhmanov/.stack/snapshots/x86_64-osx/b9ed0f8360016ada5efeb53015219761394cfd2d563da5d48a402d192c951f0a/9.0.1/lib/x86_64-osx-ghc-9.0.1/libHSpostgresql-libpq-0.9.4.3-4UpE2VczKgl8p7NC0fd3Q8-ghc9.0.1.dylib
I have PostgreSQL 13 installed via brew.
What is proper setup for PostgreSQL use with persistent on Macs with M1 chip?
Thanks in advance.
I was able to build persistent-postgresql having:
brew install postgresqlbrew install ghc cabal-installbrew install haskell-stackstack build --system-ghc to build my project with stack.cabal build.There some drawbacks with this approach:
> stack setup
I don't know how to install GHC for (OSX,AArch64), please install manually
brew install ghc@9 fails with recommendation to build it from source, which is unsupported and it fails indeed:
==> make
Last 15 lines from /Users/arthurfayzrakhmanov/Library/Logs/Homebrew/ghc@9/04.make:
adc %eax, %eax
^
tmp-add_n.s:179:6: error: invalid operand
adc %eax, %eax
^
make[4]: *** [add_n.lo] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [libraries/ghc-bignum/gmp/gmp.h] Error 2<... CUT ....>
make: *** [all] Error 2
Do not report this issue to Homebrew/brew or Homebrew/core!
Generally speaking, stack build tool is not needed thanks to cabal-install 3+ and nix-style store. However, in my real use case stack is required for Yesod development (yesod devel relies on stack).
Some credits
Originally, Branimir Maksimovic answered me in Haskell Cafe and suggested to use cabal instead of stack, and install GHC and cabal via homebrew.
This indeed worked, however my real use case required stack. I supposed that brewed stack could also work. In fact, this is no quite right, because stack uses system GHC to work.