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 creates a build folder if dist-newstyle is already present #10772

Open
ffaf1 opened this issue Jan 31, 2025 · 6 comments
Open

cabal run creates a build folder if dist-newstyle is already present #10772

ffaf1 opened this issue Jan 31, 2025 · 6 comments

Comments

@ffaf1
Copy link
Collaborator

ffaf1 commented Jan 31, 2025

Describe the bug
cabal run creates a build folder if dist-newstyle is already present.
Offspring of #10686.

To Reproduce

  1. Create new folder, cd into it.
  2. Create a dist-newstyle folder inside it.
  3. Create a minimal script.hs.
    #! /usr/bin/env cabal
    
    {- cabal:
    build-depends: base
                 , acme-missiles
    -}
    
    import Acme.Missiles
    
    main :: IO ()
    main = launchMissiles
    
  4. Make it executable, run it.
  5. Modify the script slightly (e.g. add a putStrLn), run it again
  6. ls -l
  7. There is a build folder.
    Expected behavior
    build/ is not created.

System information
Debian bookworm. cabal 3.15.

Additional context
This is not fixed by #10771 , but neither is a regression and once #10771 lands, not urgent.

@alt-romes
Copy link
Collaborator

FWIW, I've observed with head and 3.14 that the build folder is created regardless of whether dist-newstyle exists

@ffaf1
Copy link
Collaborator Author

ffaf1 commented Jan 31, 2025

that the build folder is created regardless of whether dist-newstyle exists

Thanks.

While bisecting, this — weirdly enough — happened only at times, while always when dist-newstyle was present.

@Bodigrim
Copy link
Collaborator

Additional context This is not fixed by #10771 , but neither is a regression and once #10771 lands, not urgent.

I use single-file scripts quite a lot and I don't think I ever encountered this bug with Cabal 3.12, so it's likely to be a regression as well, just an older one.

@ulysses4ever
Copy link
Collaborator

@ffaf1 maybe you could leave the dist-newstyle directory be and try to bisect it that way? It does sound believable that it's a regression in 3.14. Does it not reproduce on the 3.14 branch for you at all now?

@ffaf1
Copy link
Collaborator Author

ffaf1 commented Feb 3, 2025

I believe it is more complicated that a simple dist-newstyle folder. For once I have to modify the script, so the issue title is incorrect.

I will try to write a reasoned reproducer soon™.

@Bodigrim
Copy link
Collaborator

Bodigrim commented Feb 3, 2025

Here is a reproducer:

$ ll build/*/ghc*; echo '#!/usr/bin/env cabal\n{- cabal:\nbuild-depends: base\n-}\nmain :: IO ()\nmain = pure () -- '$(date) > Main.hs && chmod +x Main.hs && ./Main.hs && ll build/*/ghc*
zsh: no matches found: build/*/ghc*
drwxr-xr-x  3 andrew  staff  96 Feb  3 19:11 ./
drwxr-xr-x  3 andrew  staff  96 Feb  3 19:11 ../
drwxr-xr-x  3 andrew  staff  96 Feb  3 19:11 fake-package-0/

There was no build/*/ghc*/fake-package-0 folder before, but there is one after.

git bisect says that

7b9058328e162a4cb707b5d5b25cd1d2df66680e is the first bad commit
commit 7b9058328e162a4cb707b5d5b25cd1d2df66680e
Author: sheaf <[email protected]>
Date:   Fri Mar 29 15:19:27 2024 +0100

    Make Cabal agnostic about working directory

CC @sheaf

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

4 participants