“Unable to load package `regex-posix` … unknown symbol ‘regerror’”

298 Views Asked by At

For a new project, I have been trying to build the threepenny-gui package, something which I have done many times in the past without any trouble. This time however, I ran into an unusual error message:

> stack build
threepenny-gui     > configure
threepenny-gui     > Configuring threepenny-gui-0.9.0.0...
threepenny-gui     > build
threepenny-gui     > Preprocessing library for threepenny-gui-0.9.0.0..
threepenny-gui     > Building library for threepenny-gui-0.9.0.0..
threepenny-gui     > [ 1 of 29] Compiling Foreign.JavaScript.Include
threepenny-gui     > [ 2 of 29] Compiling Foreign.JavaScript.Resources
threepenny-gui     > ghc.exe: unable to load package `regex-posix-0.96.0.0'
threepenny-gui     > ghc.exe:  | C:\sr\snapshots\14724cfd\lib\x86_64-windows-ghc-8.8.4\regex-posix-0.96.0.0-11M5Q2Uki3ACYikP2WXOuq\HSregex-posix-0.96.0.0-11M5Q2Uki3ACYikP2WXOuq.o: unknown symbol `regerror'

--  While building package threepenny-gui-0.9.0.0 using:
      C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_3.0.1.0_ghc-8.8.4.exe --builddir=.stack-work\dist\29cc6475 build --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1
Progress 1/2

Now, a quick Google shows that this error message has been seen before — in 2010, after which it was fixed with a GHC update. I tried changing GHC versions (that output above was with GHC 8.8.4), but it didn’t work with 8.8.3 or 8.8.2 either. I also tried deleting regex-posix¹ and reinstalling it again, but that didn’t work either. At this point, I must confess that this error has completely stumped me; does anyone else have any idea what might be causing it, and if so, how can I fix it?

¹ Specifically, I removed C:\sr\snapshots\14724cfd\lib\x86_64-windows-ghc-8.8.4\regex-posix-0.96.0.0-11M5Q2Uki3ACYikP2WXOuq and C:\sr\snapshots\14724cfd\pkgdb\regex-posix-0.96.0.0-11M5Q2Uki3ACYikP2WXOuq.conf, and did ghc-pkg unregister regex-posix.

1

There are 1 best solutions below

0
On BEST ANSWER

This turned out to be a problem in regex-posix rather than threepenny-gui. This issue could be fixed by enabling the Cabal flag _regex-posix-clib. To set it, I first needed to unregister the previous version of regex-posix:

> stack --resolver lts-16.23 exec -- ghc-pkg unregister regex-posix-0.96.0.0 --force

I then needed to rebuild it with the correct flag:

> stack build regex-posix-0.96.0.0 --flag regex-posix:_regex-posix-clib --resolver lts-16.23

After which stack build threepenny-gui --resolver lts-16.23 was successful. (For some reason, I needed to specify the resolver explicitly in these commands.)