Skip to content

With v2 commands being the default, use dist-newstyle. #8833

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

philderbeast
Copy link
Collaborator

From #8832, bumps the location of the default directory where Cabal puts generated build files to (default dist-newstyle).

$ cabal run cabal -- clean --help
Up to date
Clean the package store and remove temporary files.

Usage: cabal new-clean [FLAGS]

Removes all temporary files created during the building process (.hi, .o,
preprocessed sources, etc.) and also empties out the local caches (by
default).


Flags for clean:
 -h, --help                     Show this help text
 -v, --verbose[=n]              Control verbosity (n is 0--3, default
                                verbosity level is 1)
 --builddir=DIR                 The directory where Cabal puts generated build
                                files (default dist-newstyle)
 --project-dir=DIR              Set the path of the project directory
 --project-file=FILE            Set the path of the cabal.project file
                                (relative to the project directory when
                                relative)
 -s, --save-config              Save configuration, only remove build
                                artifacts

ulysses4ever
ulysses4ever previously approved these changes Mar 7, 2023
Copy link
Collaborator

@ulysses4ever ulysses4ever left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Just in case, did you check if defaultDistPref is used anywhere besides help messages? If so, the change may have unpredictable consequences. I'm approving because I'm reckless when it comes to breaking backwards compatibilit, but other may be more cautious…

@philderbeast
Copy link
Collaborator Author

philderbeast commented Mar 7, 2023

I ran the tests locally.

$ cabal run cabal-tests -- --with-cabal=/.../cabal-install-3.9.0.0/x/cabal/build/cabal/cabal
...
456 tests, 8 skipped, 0 unexpected passes, 0 unexpected fails.
OK

I found 15 hits in 7 files for defaultDistPref. This renaming of the dist dir, I was unsure if it is safe:

-- 'cabal sdist' puts pre-generated files in the 'dist'
-- directory. This fails when a nonstandard build directory name
-- is used (as is the case with sandboxes), so we need to rename
-- the 'dist' dir here.
--
-- TODO: 'cabal get happy && cd sandbox && cabal install ../happy' still
-- fails even with this workaround. We probably can live with that.
maybeRenameDistDir :: FilePath -> IO ()
maybeRenameDistDir absUnpackedPath = do
let distDirPath = absUnpackedPath </> defaultDistPref
distDirPathTmp = absUnpackedPath </> (defaultDistPref ++ "-tmp")
distDirPathNew = absUnpackedPath </> distPref

@philderbeast
Copy link
Collaborator Author

I also noticed a hard-coded dist string that I have not changed:

clean :: PackageDescription -> CleanFlags -> IO ()
clean pkg_descr flags = do
let distPref = fromFlagOrDefault defaultDistPref $ cleanDistPref flags
notice verbosity "cleaning..."
maybeConfig <- if fromFlag (cleanSaveConf flags)
then maybeGetPersistBuildConfig distPref
else return Nothing
-- remove the whole dist/ directory rather than tracking exactly what files
-- we created in there.
chattyTry "removing dist/" $ do

@philderbeast
Copy link
Collaborator Author

philderbeast commented Mar 7, 2023

The word or abbreviation "dist" is also used in a few strings that can be found grepping for ".*\s+dist\s+.*".

putStrLn $ show c ++ " build dist suspicious"
putStrLn $ show d ++ " build dist suspicious warning"
putStrLn $ show e ++ " build dist inexcusable"

hPutStrLn stderr $ "Using dist dir: " ++ dist_dir

"install the package in the install subdirectory of the dist prefix, so it can be used without being installed"

@ulysses4ever
Copy link
Collaborator

As this touches a rather old dark corner of Cabal, I'd like to summon @gbaz to give this PR a look. Also, @Mikolaj may want to weigh in because our precious contributors deserve the best feedback in the world!

@Mikolaj
Copy link
Member

Mikolaj commented Mar 20, 2023

Thank you for the PR. From the PR description alone I can't guess if this changes the behaviour of cabal or only the help text and whether it affects only v2 or also the Setup and v1 API. If it does change the behaviour, could we list the changes with tickboxes and for each discuss the consequences (to correctness and to backward compatibility)?

Copy link
Member

@Mikolaj Mikolaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Please feel free to set the "merge_me" label

Copy link
Member

@Mikolaj Mikolaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uhoh, I've just found #7924. Could we make sure that changes in "multiple files, in separate packages" are not really needed and document here why not?

@mpickering
Copy link
Collaborator

I am not sure whether this is the right fix or not (I err towards not). As @Mikolaj points out this affects the v1- and ./Setup API so now the default location for those commands will also be dist-newstyle.

@philderbeast philderbeast force-pushed the bump/dist-to-dist-newstyle branch from 3c6c24d to 6cfc38f Compare March 22, 2025 20:41
@ulysses4ever ulysses4ever dismissed their stale review March 23, 2025 00:48

See the comments on the thread

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants