Can't run tests for `Hello World`

I get this error when I try to test my solution to the Hello World exercise.

I’ve installed GHC using GHCup on my FreeBSD 14.3 machine.

I’ve removed the middle of the output to be able to post it here. The full output is available in this Gist.

# stack test
[ Error ] [GHCup-00130] The version '9.2.7' of the tool ghc is not installed.
[ Info  ] downloading: https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-0.0.9.yaml as file /root/.ghcup/cache/ghcup-0.0.9.yaml
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
[ Warn  ] New ghc version available. If you want to install this latest version, run 'ghcup install ghc 9.12.2'
[ Warn  ] New cabal version available. If you want to install this latest version, run 'ghcup install cabal 3.16.0.0'
[ Warn  ] New hls version available. If you want to install this latest version, run 'ghcup install hls 2.12.0.0'
[ Warn  ] New stack version available. If you want to install this latest version, run 'ghcup install stack 3.7.1'
[ Info  ] downloading: https://downloads.haskell.org/ghcup/unofficial-bindists/ghc/9.2.7/ghc-9.2.7-x86_64-portbld-freebsd.tar.xz as file /root/.ghcup/tmp/ghcup-1c1e3400272b39d0/ghc-9.2.7-x86_64-portbld-freebsd.tar.xz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  106M  100  106M    0     0  2609k      0  0:00:41  0:00:41 --:--:-- 2948k
[ Info  ] verifying digest of: ghc-9.2.7-x86_64-portbld-freebsd.tar.xz
[ Info  ] Unpacking: ghc-9.2.7-x86_64-portbld-freebsd.tar.xz to /root/.ghcup/tmp/ghcup-6d43d0a4bac35f46
[ Info  ] Installing GHC (this may take a while)
[ Info  ] Merging file tree from "/root/.ghcup/tmp/ghcup-c11a118ab87882a6/root/.ghcup/ghc/9.2.7" to "/root/.ghcup/ghc/9.2.7"
[ Info  ] GHC installation successful
[1 of 2] Compiling Main             ( /root/.stack/setup-exe-src/setup-w2MFVN35.hs, /root/.stack/setup-exe-src/setup-w2MFVN35.o )
[2 of 2] Compiling StackSetupShim   ( /root/.stack/setup-exe-src/setup-shim-w2MFVN35.hs, /root/.stack/setup-exe-src/setup-shim-w2MFVN35.o )
Linking /root/.stack/setup-exe-cache/x86_64-freebsd/tmp-Cabal-simple_w2MFVN35_3.6.3.0_ghc-9.2.7 ...
/usr/local/bin/ld: warning: win64.o: missing .note.GNU-stack section implies executable stack
/usr/local/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
call-stack        > configure
clock             > configure
colour            > configure
hspec-discover    > configure
clock             > Configuring clock-0.8.3...
colour            > Configuring colour-2.3.6...
call-stack        > Configuring call-stack-0.4.0...
hspec-discover    > Configuring hspec-discover-2.9.7...
clock             > build with ghc-9.2.7
colour            > build with ghc-9.2.7
call-stack        > build with ghc-9.2.7
hspec-discover    > build with ghc-9.2.7
clock             > Preprocessing library for clock-0.8.3..
colour            > Preprocessing library for colour-2.3.6..
colour            > Building library for colour-2.3.6..
call-stack        > Preprocessing library for call-stack-0.4.0..
call-stack        > Building library for call-stack-0.4.0..
hspec-discover    > Preprocessing library for hspec-discover-2.9.7..
hspec-discover    > Building library for hspec-discover-2.9.7..
clock             > compiling .stack-work/dist/x86_64-freebsd/ghc-9.2.7/build/System/Clock_hsc_make.c failed (exit code 1)
clock             > rsp file was: ".stack-work/dist/x86_64-freebsd/ghc-9.2.7/build/System/hsc2hscall31052-0.rsp"
clock             > command was: /usr/local/bin/gcc -c .stack-work/dist/x86_64-freebsd/ghc-9.2.7/build/System/Clock_hsc_make.c -o .stack-work/dist/x86_64-freebsd/ghc-9.2.7/build/System/Clock_hsc_make.o --target=x86_64-portbld-freebsd--lflag=--target=x86_64-portbld-freebsd -D__GLASGOW_HASKELL__=902 -Dfreebsd_BUILD_OS=1 -Dx86_64_BUILD_ARCH=1 -Dfreebsd_HOST_OS=1 -Dx86_64_HOST_ARCH=1 -Icbits -I.stack-work/dist/x86_64-freebsd/ghc-9.2.7/build/cbits -I.stack-work/dist/x86_64-freebsd/ghc-9.2.7/build/autogen -I.stack-work/dist/x86_64-freebsd/ghc-9.2.7/build/global-autogen -include .stack-work/dist/x86_64-freebsd/ghc-9.2.7/build/autogen/cabal_macros.h -I/usr/local/include -I/root/.ghcup/ghc/9.2.7/lib/ghc-9.2.7/lib/../lib/x86_64-freebsd-ghc-9.2.7/base-4.16.4.0/include -I/usr/local/include -I/root/.ghcup/ghc/9.2.7/lib/ghc-9.2.7/lib/../lib/x86_64-freebsd-ghc-9.2.7/ghc-bignum-1.2/include -I/root/.ghcup/ghc/9.2.7/lib/ghc-9.2.7/lib/../lib/x86_64-freebsd-ghc-9.2.7/rts-1.0.2/include -I/root/.ghcup/ghc/9.2.7/include/
clock             > error: gcc: error: unrecognized command-line option '--target=x86_64-portbld-freebsd--lflag=--target=x86_64-portbld-freebsd'
clock             >
colour            > [ 1 of 14] Compiling Data.Colour.CIE.Chromaticity
hspec-discover    > [1 of 4] Compiling Paths_hspec_discover
call-stack        > [1 of 3] Compiling Data.SrcLoc
call-stack        > [2 of 3] Compiling Data.CallStack
call-stack        > [3 of 3] Compiling Paths_call_stack
hspec-discover    > [2 of 4] Compiling Test.Hspec.Discover.Config
colour            > [ 2 of 14] Compiling Data.Colour.CIE.Illuminant
colour            > [ 3 of 14] Compiling Data.Colour.Chan
colour            > [ 4 of 14] Compiling Data.Colour.Internal
hspec-discover    > [3 of 4] Compiling Test.Hspec.Discover.Sort
[...]
QuickCheck        > [ 4 of 16] Compiling Test.QuickCheck.Gen.Unsafe
QuickCheck        > [ 5 of 16] Compiling Test.QuickCheck.Arbitrary
tf-random         > copy/register
tf-random         > Installing library in /root/.stack/snapshots/x86_64-freebsd/55050888633c22498845fddfee0f671bd441c0fb1e9cf1be9cd6e8c861feb2bd/9.2.7/lib/x86_64-freebsd-ghc-9.2.7/tf-random-0.5-2MuOk48NljZ63zvvppAh3N
tf-random         > Registering library for tf-random-0.5..
QuickCheck        > [ 6 of 16] Compiling Test.QuickCheck.Poly
QuickCheck        > [ 7 of 16] Compiling Test.QuickCheck.Modifiers
QuickCheck        > [ 8 of 16] Compiling Test.QuickCheck.Function
QuickCheck        > [ 9 of 16] Compiling Test.QuickCheck.Text
QuickCheck        > [10 of 16] Compiling Test.QuickCheck.State
QuickCheck        > [11 of 16] Compiling Test.QuickCheck.Property
QuickCheck        >
QuickCheck        > /tmp/stack-f6d6b416dd1701c4/QuickCheck-2.14.2/src/Test/QuickCheck/Property.hs:220:3: warning: [-Wnoncanonical-monad-instances]
QuickCheck        >     Noncanonical ‘pure = return’ definition detected
QuickCheck        >     in the instance declaration for ‘Applicative Rose’.
QuickCheck        >     Move definition from ‘return’ to ‘pure’
QuickCheck        >     See also: https://gitlab.haskell.org/ghc/ghc/-/wikis/proposal/monad-of-no-return
QuickCheck        >     |
QuickCheck        > 220 |   pure = return
QuickCheck        >     |   ^^^^^^^^^^^^^
QuickCheck        >
QuickCheck        > /tmp/stack-f6d6b416dd1701c4/QuickCheck-2.14.2/src/Test/QuickCheck/Property.hs:225:3: warning: [-Wnoncanonical-monad-instances]
QuickCheck        >     Noncanonical ‘return’ definition detected
QuickCheck        >     in the instance declaration for ‘Monad Rose’.
QuickCheck        >     ‘return’ will eventually be removed in favour of ‘pure’
QuickCheck        >     Either remove definition for ‘return’ (recommended) or define as ‘return = pure’
QuickCheck        >     See also: https://gitlab.haskell.org/ghc/ghc/-/wikis/proposal/monad-of-no-return
QuickCheck        >     |
QuickCheck        > 225 |   return x = MkRose x []
QuickCheck        >     |   ^^^^^^^^^^^^^^^^^^^^^^
QuickCheck        > [12 of 16] Compiling Test.QuickCheck.Test
QuickCheck        > [13 of 16] Compiling Test.QuickCheck.Monadic
QuickCheck        > [14 of 16] Compiling Test.QuickCheck.All
QuickCheck        > [15 of 16] Compiling Test.QuickCheck.Features
QuickCheck        > [16 of 16] Compiling Test.QuickCheck
QuickCheck        > copy/register
QuickCheck        > Installing library in /root/.stack/snapshots/x86_64-freebsd/55050888633c22498845fddfee0f671bd441c0fb1e9cf1be9cd6e8c861feb2bd/9.2.7/lib/x86_64-freebsd-ghc-9.2.7/QuickCheck-2.14.2-4D44XnLgnpBFIBDe1Au7Zw
QuickCheck        > Registering library for QuickCheck-2.14.2..
quickcheck-io     > configure
quickcheck-io     > Configuring quickcheck-io-0.2.0...
quickcheck-io     > build with ghc-9.2.7
quickcheck-io     > Preprocessing library for quickcheck-io-0.2.0..
quickcheck-io     > Building library for quickcheck-io-0.2.0..
quickcheck-io     > [1 of 2] Compiling Paths_quickcheck_io
quickcheck-io     > [2 of 2] Compiling Test.QuickCheck.IO
quickcheck-io     > copy/register
quickcheck-io     > Installing library in /root/.stack/snapshots/x86_64-freebsd/55050888633c22498845fddfee0f671bd441c0fb1e9cf1be9cd6e8c861feb2bd/9.2.7/lib/x86_64-freebsd-ghc-9.2.7/quickcheck-io-0.2.0-DkeX1L711pPEOCkfVlZLuO
quickcheck-io     > Registering library for quickcheck-io-0.2.0..
Progress 14/18

Error: [S-7282]
       Stack failed to execute the build plan.

       While executing the build plan, Stack encountered the error:

       [S-7011]
       While building package clock-0.8.3 (scroll up to its section to see the error) using:
       /root/.stack/setup-exe-cache/x86_64-freebsd/Cabal-simple_w2MFVN35_3.6.3.0_ghc-9.2.7 --verbose=1 --builddir=.stack-work/dist/x86_64-freebsd/ghc-9.2.7 build --ghc-options " -fdiagnostics-color=always"
       Process exited with code: ExitFailure 1
  stack test
  ^~~~~

This is very similar to this, and involves the same GHC version, the same library and the same OS. So maybe the same solution applies?

Thanks! It does look similar, but I’m unsure. For example, the blog post says that ~/.ghcup/bin/hsc2hs should contain

HSC2HS_EXTRA="--cflag=--target=x86_64-portbld-freebsd--lflag=--target=x86_64-portbld-freebsd --lflag=-fuse-ld=lld"

but on my machine it says

HSC2HS_EXTRA="$cflags $lflags"

The author wrote that he would ask the GHC devs for advice where to report the bug, but I couldn’t find any relevant bug report in the GHC, cabal, and hsc2hs repos.

When testing after upgrading the stack minor version to the latest for GHC 9.2.* (lts-20.26) I get another error message, but an error still the same.

I tested the latest versions of Stack’s LTS resolvers for later minor versions of 9.4+, and that solves my problem.

Has there been any discussions about updating the stack snapshot?

Not that I’m aware, no. Let me ping the track maintainers.

cc @tofische @MatthijsBlom

1 Like

Created PR 1292 that changes the resolver from 20.18 to 24.19.

Upgrading the version requires updating much more than just those files :slightly_smiling_face:
The whole framework that runs the tests needs updating, along with any relevant documentation. Plus possibly more that I’m not aware of. Let’s see what the track maintainers think.

1 Like

It has gone eleven days since the last reply in this thread. Ping @tofische and @MatthijsBlom again :)