'cannot start GHCi & cabal linker error, `undefined reference to ...`

This problem started out of nowhere and I'm not sure what causes it.

Whenever I try to start up GHCi, it gives me an error

> ghci
GHCi, version 8.6.5: http://www.haskell.org/ghc/  :? for help
Loaded package environment from /home/aradarbel10/dev/SetLang/.ghc.environment.x86_64-linux-8.6.5
<command line>: can't load .so/.DLL for: /home/aradarbel10/dev/SetLang/dist-newstyle/build/x86_64-linux/ghc-8.6.5/SetLang-0.1.0.0/build/libHSSetLang-0.1.0.0-inplace-ghc8.6.5.so (/home/aradarbel10/dev/SetLang/dist-newstyle/build/x86_64-linux/ghc-8.6.5/SetLang-0.1.0.0/build/libHSSetLang-0.1.0.0-inplace-ghc8.6.5.so: undefined symbol: SetLangzm0zi1zi0zi0zminplace_EUF_satisfiable_closure)

the problem seems to arise from one of my files, EUF.hs. I can fix this by deleting the .ghc.environment.x86_64-linux-8.6.5 file inside the directory, but then when I run cabal it gets regenerated.

trying to run with cabal also doesn't work, although it used to:

> cabal new-run SetLang-exe
Build profile: -w ghc-8.6.5 -O1
In order, the following will be built (use -v for more details):
 - SetLang-0.1.0.0 (exe:SetLang-exe) (first run)
Preprocessing executable 'SetLang-exe' for SetLang-0.1.0.0..
Building executable 'SetLang-exe' for SetLang-0.1.0.0..
Linking /home/aradarbel10/dev/SetLang/dist-newstyle/build/x86_64-linux/ghc-8.6.5/SetLang-0.1.0.0/x/SetLang-exe/build/SetLang-exe/SetLang-exe ...
/home/aradarbel10/dev/SetLang/dist-newstyle/build/x86_64-linux/ghc-8.6.5/SetLang-0.1.0.0/build/libHSSetLang-0.1.0.0-inplace.a(Mather.o):SetLangzm0zi1zi0zi0zminplace_Mather_zdfTheoryPredExpr0zuzdcvar_info: error: undefined reference to 'SetLangzm0zi1zi0zi0zminplace_EUF_Expr_con_info'
/home/aradarbel10/dev/SetLang/dist-newstyle/build/x86_64-linux/ghc-8.6.5/SetLang-0.1.0.0/build/libHSSetLang-0.1.0.0-inplace.a(Mather.o)(.data+0x2710): error: undefined reference to 'SetLangzm0zi1zi0zi0zminplace_EUF_zdfOrdPred_closure'
/home/aradarbel10/dev/SetLang/dist-newstyle/build/x86_64-linux/ghc-8.6.5/SetLang-0.1.0.0/build/libHSSetLang-0.1.0.0-inplace.a(Mather.o)(.data+0x2728): error: undefined reference to 'SetLangzm0zi1zi0zi0zminplace_EUF_Eq_closure'

< some more undefined references ...... >

collect2: error: ld returned 1 exit status
`x86_64-linux-gnu-gcc' failed in phase `Linker'. (Exit code: 1)

From this I believe there's some problem with the linker, but again idk why exactly it happens.
I've already tried completely reinstalling both GHC and cabal, including manually removing their .ghc and .cabal folders to make sure nothing is cached, but the problem still occurs.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source