Missing Pre-processor Command Error Message
Summary
I was using hspec-discover and had forgotten to add build-tools: hspec-discover
in my cabal file. When I tried running the tests i received the following unhelpful error message
$ cabal test -O0
Resolving dependencies...
Build profile: -w ghc-9.2.7 -O0
In order, the following will be built (use -v for more details):
- biparsing-core-0.0.0.1 (lib) (configuration changed)
- biparsing-core-0.0.0.1 (test:spec) (configuration changed)
Configuring library for biparsing-core-0.0.0.1..
Preprocessing library for biparsing-core-0.0.0.1..
Building library for biparsing-core-0.0.0.1..
Configuring test suite 'spec' for biparsing-core-0.0.0.1..
Preprocessing test suite 'spec' for biparsing-core-0.0.0.1..
Building test suite 'spec' for biparsing-core-0.0.0.1..
tests/Spec.hs:1:1: error:
hspec-discover: builderMainLoop: exec: invalid argument (Bad file descriptor)
|
1 | {-# OPTIONS_GHC -F -pgmF hspec-discover #-}
| ^
this error seems to indicate that there is some bad file descriptor in the Spec.hs file and gives a line number where to look.
The actual problem is that the command hspec-discover
cannot be found in PATH. I would have expected an error more like
The command hspec-discover could not be found for pre-processing tests/Spec.hs
Related issue in hspec https://github.com/hspec/hspec/issues/879
Steps to reproduce
echo '{-# OPTIONS_GHC -F -pgmF not-a-real-command #-}' > /tmp/pre-processor-error.hs
ghc /tmp/pre-processor-error.hs
Expected behavior
The following compilation error should be output
Loaded package environment from /home/wjr/.ghc/x86_64-openbsd-9.2.7/environments/default
/tmp/pre-processor-error.hs:1:1: error:
not-a-real-command: builderMainLoop: exec: invalid argument (Bad file descriptor)
|
1 | {-# OPTIONS_GHC -F -pgmF not-a-real-command #-}
| ^
Environment
- GHC version used: 9.2.7
Optional:
- Operating System: OpenBSD 7.4
- System Architecture: x86_64