Skip to content

cabal triggers a full build each time a script is executed #6354

Closed

Description

@jneira

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.0
  • ghc versions: tested with 8.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.

Activity

  1. jneira commented on Oct 19, 2021

    @jneira
    MemberAuthor

    Related with:

  2. added a commit that references this issue on Dec 1, 2021
    92e5f14
  3. linked a pull request that will close this issueBetter support for running scripts. #7851on Dec 3, 2021
  4. added 2 commits that reference this issue on Dec 23, 2021
    7946c3c
    cd66349
  5. added 2 commits that reference this issue on Dec 31, 2021
    0966e4e
    856134d
  6. added a commit that references this issue on Dec 31, 2021
    bbc11f1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions