Haskell-language-server: Error in install.hs script with -haddock enabled: "parse error on input `import`"

Created on 23 Jul 2020  Â·  5Comments  Â·  Source: haskell/haskell-language-server

Hi!

I was following the install instructions... and immediately after cloning, this pops:

$ cabal v2-run install.hs --project-file install/shake.project help
Resolving dependencies...
Build profile: -w ghc-8.10.1 -O1
In order, the following will be built (use -v for more details):
 - fake-package-0 (exe:script) (configuration changed)
Configuring executable 'script' for fake-package-0..
Preprocessing executable 'script' for fake-package-0..
Building executable 'script' for fake-package-0..
[1 of 1] Compiling Main             ( Main.hs, /home/ulidtko/src/haskell-language-server/dist-newstyle/build/x86_64-linux/ghc-8.10.1/fake-package-0/x/script/build/script/script-tmp/Main.dyn_o )

Main.hs:18:1: error: parse error on input ‘import’
   |

Ehhhh... wat. This is apparently about the 19th line of install.hs. What's wrong?

build can-workaround install bug

Most helpful comment

Ok i was able to reproduce it with

cabal v2-run install.hs --ghc-options "-haddock" --project-file install/shake.project help

But no with a raw

cabal v2-run install.hs  --project-file install/shake.project help

so the unique other way to trigger it i can imagine is to have in install/shake.project or in the global cabal config --haddock in ghc params, as described in the readme . Note that there is a warning about enabling globally the option, because it can cause parse errors like yours.

So i would advise to not set the flag globally, only for individual projects.

All 5 comments

Yeah that's weird, what version of cabal-install are you using?

> cabal --version
cabal-install version 3.2.0.0
compiled using version 3.2.0.0 of the Cabal library 

GHC 8.10.1. System is Arch Linux.

Ok i was able to reproduce it with

cabal v2-run install.hs --ghc-options "-haddock" --project-file install/shake.project help

But no with a raw

cabal v2-run install.hs  --project-file install/shake.project help

so the unique other way to trigger it i can imagine is to have in install/shake.project or in the global cabal config --haddock in ghc params, as described in the readme . Note that there is a warning about enabling globally the option, because it can cause parse errors like yours.

So i would advise to not set the flag globally, only for individual projects.

@jneira thanks. I thought more than once about the -haddock (I did add it globally), but somehow the Compiling Main line just above (and no Linking line after it) has convinced me that it's not docs.

So this is Haddock not "getting" the shebang, right? It's still weird that it doesn't understand the import keyword.

Yeah, cabal/stack scripts feature is relatively recent and it is not widely used, so the interaction with haddock has not been tested.
The resolution could be:

  • change the script to make haddock happy, thing that might be not possible
  • open an issue upstream (in haddock i suppose)

We have to take in account -haddock errors are going to be demoted to warnings, hopefully soon.

Was this page helpful?
0 / 5 - 0 ratings