Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cabal run --dry-run runs executable if it has been built before #7203

Closed
adamgundry opened this issue Dec 18, 2020 · 2 comments
Closed

cabal run --dry-run runs executable if it has been built before #7203

adamgundry opened this issue Dec 18, 2020 · 2 comments

Comments

@adamgundry
Copy link
Member

Suppose the current project has a foo executable that has been built already (e.g. via cabal v2-build foo). Then cabal v2-run foo --dry-run will re-run dependency solving and display a "the following would be built" message without actually building anything (as expected), but then will run the existing executable.

Is this intended? I would expect cabal v2-run foo --dry-run to behave like cabal v2-build foo --dry-run, i.e. print out the dependencies to be built but not actually run anything. I can't see documentation in the manual for --dry-run, and the --help text says

    --dry-run  Do not install anything, only print what would be installed.

Tested with cabal 3.4 on Linux.

@phadej
Copy link
Collaborator

phadej commented Dec 18, 2020

That looks like a bug.

% /opt/cabal/3.2/bin/cabal run initialization --dry-run
Resolving dependencies...
Build profile: -w ghc-8.6.5 -O1
In order, the following would be built (use -v for more details):
 - splitmix-0.1.0.3 (lib) (cannot read state cache)
 - splitmix-0.1.0.3 (test:initialization) (first run)
/code/public-haskell/splitmix/dist-newstyle/build/x86_64-linux/ghc-8.6.5/splitmix-0.1.0.3/t/initialization/build/initialization/initialization: createProcess: runInteractiveProcess: exec: does not exist (No such file or directory)

I.e. it indeed doesn't build, but it runs (and if there's something, it will succeed).

I can imagine the use case for that, but --dry-run is not a flag I'd imagine for that. Also because, cabal test --dry-run doesn't run test suites...

% /opt/cabal/3.2/bin/cabal test initialization --dry-run
Resolving dependencies...
Build profile: -w ghc-8.6.5 -O1
In order, the following would be built (use -v for more details):
 - splitmix-0.1.0.3 (lib) (cannot read state cache)
 - splitmix-0.1.0.3 (test:initialization) (first run)

That said, cabal v2-build, cabal v2-run, cabal v2-test with --dry-run would all do the same, so if v2-build works, use that for now.

@fgaz
Copy link
Member

fgaz commented May 3, 2021

Closing in favor of the bigger #7379. PRs still welcome :)

@fgaz fgaz closed this as completed May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants