Stack install fails with linker errors when building system-filepath after update to 10.15 catalina

catalinadevelopmentterminal

I have the latest haskell-stack from Homebrew, and am trying to install turtle for scripting. However, it fails when building system-filepath, one of its dependencies.

Here is a reduced example:

$ stack install system-filepath
stack install system-filepath
system-filepath> configure
system-filepath> [1 of 2] Compiling Main             ( /private/var/folders/7f/fs_469bj5pv8dqm2pk_75gv00000gn/T/stack-3ff4da100e1795d8/system-filepath-0.4.14/Setup.hs, /private/var/folders/7f/fs_469bj5pv8dqm2pk_75gv00000gn/T/stack-3ff4da100e1795d8/system-filepath-0.4.14/.stack-work/dist/x86_64-osx/Cabal-2.4.0.1/setup/Main.o )
system-filepath> 
system-filepath> /private/var/folders/7f/fs_469bj5pv8dqm2pk_75gv00000gn/T/stack-3ff4da100e1795d8/system-filepath-0.4.14/Setup.hs:7:1: warning: [-Wtabs]
system-filepath>     Tab character found here, and in 9 further locations.
system-filepath>     Please use spaces instead.
system-filepath>   |
system-filepath> 7 |         hooks = Simple.simpleUserHooks
system-filepath>   | ^^^^^^^^
system-filepath> [2 of 2] Compiling StackSetupShim   ( /Users/albin/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, /private/var/folders/7f/fs_469bj5pv8dqm2pk_75gv00000gn/T/stack-3ff4da100e1795d8/system-filepath-0.4.14/.stack-work/dist/x86_64-osx/Cabal-2.4.0.1/setup/StackSetupShim.o )
system-filepath> Linking /private/var/folders/7f/fs_469bj5pv8dqm2pk_75gv00000gn/T/stack-3ff4da100e1795d8/system-filepath-0.4.14/.stack-work/dist/x86_64-osx/Cabal-2.4.0.1/setup/setup ...
system-filepath> ld: warning: ignoring file /Users/albin/.stack/snapshots/x86_64-osx/89b028f4df1ab2c9ef46bc647dfd20f8bc49fdf794d89449ebec3484fe5fed43/8.6.5/lib/x86_64-osx-ghc-8.6.5/Cabal-2.4.1.0-3JC906oWQ73Ah7bYkIcI4J/libHSCabal-2.4.1.0-3JC906oWQ73Ah7bYkIcI4J.a, building for macOS-x86_64 but attempting to link with file built for macOS-x86_64
system-filepath> ld: warning: ignoring file /Users/albin/.stack/snapshots/x86_64-osx/89b028f4df1ab2c9ef46bc647dfd20f8bc49fdf794d89449ebec3484fe5fed43/8.6.5/lib/x86_64-osx-ghc-8.6.5/parsec-3.1.14.0-8t8UKeFouAo5hdmomuIjPj/libHSparsec-3.1.14.0-8t8UKeFouAo5hdmomuIjPj.a, building for macOS-x86_64 but attempting to link with file built for macOS-x86_64
system-filepath> Undefined symbols for architecture x86_64:
system-filepath>   "_Cabalzm2zi4zi1zi0zm3JC906oWQ73Ah7bYkIcI4J_DistributionziSimple_defaultMainWithHooks_closure", referenced from:
system-filepath>       _Main_main_info in Main.o
system-filepath>       _u89i_srt in Main.o
system-filepath>       _c9mn_info in StackSetupShim.o
system-filepath>       _u9no_srt in StackSetupShim.o
system-filepath>   "_Cabalzm2zi4zi1zi0zm3JC906oWQ73Ah7bYkIcI4J_DistributionziSimpleziUserHooks_replHook_closure", referenced from:
system-filepath>       _c9gw_info in StackSetupShim.o
system-filepath>       _c9gK_info in StackSetupShim.o
system-filepath>       _u9jF_srt in StackSetupShim.o
system-filepath>   "_Cabalzm2zi4zi1zi0zm3JC906oWQ73Ah7bYkIcI4J_DistributionziSimpleziBuild_initialBuildSteps_closure", referenced from:
system-filepath>       _c9gP_info in StackSetupShim.o
system-filepath>       _u9jE_srt in StackSetupShim.o
system-filepath>   "_Cabalzm2zi4zi1zi0zm3JC906oWQ73Ah7bYkIcI4J_DistributionziSimpleziSetup_replDistPref_closure", referenced from:
system-filepath>       _s9bv_info in StackSetupShim.o
system-filepath>       _u9jA_srt in StackSetupShim.o
system-filepath>   "_Cabalzm2zi4zi1zi0zm3JC906oWQ73Ah7bYkIcI4J_DistributionziSimpleziSetup_replVerbosity_closure", referenced from:
system-filepath>       _s9bI_info in StackSetupShim.o
system-filepath>       _u9jC_srt in StackSetupShim.o
system-filepath>   "_Cabalzm2zi4zi1zi0zm3JC906oWQ73Ah7bYkIcI4J_DistributionziSimple_simpleUserHooks_closure", referenced from:
system-filepath>       _s85g_info in Main.o
system-filepath>       _u88h_srt in Main.o
system-filepath>       _c9gw_info in StackSetupShim.o
system-filepath>       _c9gK_info in StackSetupShim.o
system-filepath>       _s9cS_info in StackSetupShim.o
system-filepath>       _u9jF_srt in StackSetupShim.o
system-filepath>       _u9nn_srt in StackSetupShim.o
system-filepath>       ...
system-filepath>   "_Cabalzm2zi4zi1zi0zm3JC906oWQ73Ah7bYkIcI4J_DistributionziSimpleziFlag_fromFlag_closure", referenced from:
system-filepath>       _s9bJ_info in StackSetupShim.o
system-filepath>       _s9bw_info in StackSetupShim.o
system-filepath>       _u9jB_srt in StackSetupShim.o
system-filepath>       _u9jD_srt in StackSetupShim.o
system-filepath>   "_Cabalzm2zi4zi1zi0zm3JC906oWQ73Ah7bYkIcI4J_DistributionziSimpleziProgramziDb_userSpecifyArgs_closure", referenced from:
system-filepath>       _s85d_info in Main.o
system-filepath>       _u88c_srt in Main.o
system-filepath>   "_Cabalzm2zi4zi1zi0zm3JC906oWQ73Ah7bYkIcI4J_DistributionziTypesziHookedBuildInfo_emptyHookedBuildInfo_closure", referenced from:
system-filepath>       _s9cE_info in StackSetupShim.o
system-filepath>       _u9nk_srt in StackSetupShim.o
system-filepath>   "_Cabalzm2zi4zi1zi0zm3JC906oWQ73Ah7bYkIcI4J_DistributionziSimpleziUserHooks_haddockHook_closure", referenced from:
system-filepath>       _s85f_info in Main.o
system-filepath>       _u88f_srt in Main.o
system-filepath>   "_Cabalzm2zi4zi1zi0zm3JC906oWQ73Ah7bYkIcI4J_DistributionziTypesziLocalBuildInfo_LocalBuildInfo_con_info", referenced from:
system-filepath>       _c87f_info in Main.o
system-filepath>   "_Cabalzm2zi4zi1zi0zm3JC906oWQ73Ah7bYkIcI4J_DistributionziSimpleziUserHooks_UserHooks_con_info", referenced from:
system-filepath>       _c871_info in Main.o
system-filepath>       _c9mw_info in StackSetupShim.o
system-filepath>   "_Cabalzm2zi4zi1zi0zm3JC906oWQ73Ah7bYkIcI4J_DistributionziTypesziLocalBuildInfo_withPrograms_closure", referenced from:
system-filepath>       _s85c_info in Main.o
system-filepath>       _u88b_srt in Main.o
system-filepath> ld: symbol(s) not found for architecture x86_64
system-filepath> clang: error: linker command failed with exit code 1 (use -v to see invocation)
system-filepath> `gcc' failed in phase `Linker'. (Exit code: 1)

--  While building package system-filepath-0.4.14 using:
      /Users/albin/.stack/programs/x86_64-osx/ghc-8.6.5/bin/ghc-8.6.5 --make -odir /private/var/folders/7f/fs_469bj5pv8dqm2pk_75gv00000gn/T/stack-3ff4da100e1795d8/system-filepath-0.4.14/.stack-work/dist/x86_64-osx/Cabal-2.4.0.1/setup -hidir /private/var/folders/7f/fs_469bj5pv8dqm2pk_75gv00000gn/T/stack-3ff4da100e1795d8/system-filepath-0.4.14/.stack-work/dist/x86_64-osx/Cabal-2.4.0.1/setup -i -i. -clear-package-db -global-package-db -package-db=/Users/albin/.stack/snapshots/x86_64-osx/89b028f4df1ab2c9ef46bc647dfd20f8bc49fdf794d89449ebec3484fe5fed43/8.6.5/pkgdb -package-db=/Users/albin/.stack/global-project/.stack-work/install/x86_64-osx/89b028f4df1ab2c9ef46bc647dfd20f8bc49fdf794d89449ebec3484fe5fed43/8.6.5/pkgdb -hide-all-packages -package-id=Cabal-2.4.1.0-3JC906oWQ73Ah7bYkIcI4J -package-id=base-4.12.0.0 -optP-include -optP/private/var/folders/7f/fs_469bj5pv8dqm2pk_75gv00000gn/T/stack-3ff4da100e1795d8/system-filepath-0.4.14/.stack-work/dist/x86_64-osx/Cabal-2.4.0.1/setup/setup_macros.h /private/var/folders/7f/fs_469bj5pv8dqm2pk_75gv00000gn/T/stack-3ff4da100e1795d8/system-filepath-0.4.14/Setup.hs /Users/albin/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs -main-is StackSetupShim.mainOverride -o /private/var/folders/7f/fs_469bj5pv8dqm2pk_75gv00000gn/T/stack-3ff4da100e1795d8/system-filepath-0.4.14/.stack-work/dist/x86_64-osx/Cabal-2.4.0.1/setup/setup -threaded
    Process exited with code: ExitFailure 1

In particular, the error building for macOS-x86_64 but attempting to link with file built for macOS-x86_64 looks deeply unsound to me.

Best Answer

I have solved this by:

  1. uninstalling homebrew
  2. deleting ~/.stack
  3. cleaning out everything I could get my hands on in /usr/local
  4. reinstalling homebrew
  5. reinstalling stack from homebrew

I guess I will never know what precisely fixed this, but something did. Reinstalling stack was not previously enough.