Repository navigation
Closed
Description
Describe the bug
cabal triggers a full build each time a script is executed instead reuse the previous one
To Reproduce
Steps to reproduce the behavior:
given a simple script:
#!/usr/bin/env cabal
{- cabal:
build-depends:
base
-}
main = putStrLn "hello"- we can observe executing it twice
D:\ws\haskell\cabal-test>cabal v2-run script.hs
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) (first run)
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, D:\ws\haskell\cabal-test\dist-new
style\build\x86_64-windows\ghc-8.6.5\fake-package-0\x\script\build\script\script
-tmp\Main.o )
Linking D:\ws\haskell\cabal-test\dist-newstyle\build\x86_64-windows\ghc-8.6.5\fa
ke-package-0\x\script\build\script\script.exe ...
hello
D:\ws\haskell\cabal-test>cabal v2-run script.hs
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, D:\ws\haskell\cabal-test\dist-new
style\build\x86_64-windows\ghc-8.6.5\fake-package-0\x\script\build\script\script
-tmp\Main.o )
Linking D:\ws\haskell\cabal-test\dist-newstyle\build\x86_64-windows\ghc-8.6.5\fa
ke-package-0\x\script\build\script\script.exe ...
hello
that the executable is built and linked every time
Expected behavior
The executable installed the first time should be reused like executing cabal v2-run target in a project
System information
- Operating system: windows
cabal: 3.0.0.0ghcversions: tested with8.6.5
Additional context
With scripts that has a medium size (like the used one in haskell-ide-engine) the full build may take enough time to miss using the previous one.
Reacted by George Thomas
Activity
jneira commentedon Oct 19, 2021
Related with:
the underlying causeit is related with the use of a fake packageAdd support for script build caching to cabal run
Update documentation for better script support
Add support for script build caching to cabal run
Update documentation for better script support
Add support for script build caching to cabal run
Update documentation for better script support
Add support for script build caching to cabal run
Update documentation for better script support
Better support for running scripts. (#7851)