Describe the bug
Attempting to use cabal as script interpreter seems to not work in windows, even using mingw64 shell
To Reproduce
Steps to reproduce the behavior:
Create a test.hs file:
#!/usr/bin/env cabal
{- cabal:
with-compiler: ghc-8.6.5
build-depends: base
-}
main :: IO()
main = putStrLn "Interpret me please"
cabal v2-run test.hs command in a dos shell./test.hs in a mingw shellExpected behavior
The script should be interpreted and show the message
Actual behavior
Resolving dependencies...
Build profile: -w ghc-8.6.5 -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, \path\to\test-interpreter\di
st-newstyle\build\x86_64-windows\ghc-8.6.5\fake-package-0\x\script\build\script\
script-tmp\Main.o )
Main.hs:1:1: error:
Could not load module ‘Prelude’
It is a member of the hidden package ‘base-4.12.0.0’.
Perhaps you need to add ‘base’ to the build-depends in your .cabal file.ile.
it is a hidden module in the package ‘hackage-security-0.5.3.0’
Use -v to see a list of the files searched for.
|
1 | {- cabal:
| ^
System informataion
cabal cabal-install version 2.4.1.0
compiled using version 2.4.1.0 of the Cabal library
Additional context
Trying to build haskell-ide-engine with cabal, using the script feature: https://github.com/haskell/haskell-ide-engine/pull/1221
@jneira can you try with either cabal HEAD, or with the tip of the 2.4 branch? As you can see from https://github.com/haskell/cabal/blob/2.4/cabal-install/changelog there were a couple fixes done for a cabal 2.4.2 point release which might fix your issue
possible duplicate of #5775
Arrgh i cant believe i missed that one in my search, sorry for that.
Trying with cabal built from 2.4 branch works as expected.
Thanks for the point, closing this as duplicate of #5775