You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Per package/component cabal clean (add support for targets) #7506
cabal clean is both simple and effective, by virtue of just deleting everything. However, in a multi-package project, I usually want to clean just one package or component that I'm working on.
Of course, the current implementation works for this, but once you accrue a few local packages and a few source-repository-packages, redoing all the work instead of just the last bit becomes painful.
At the moment I work around this by deleting targeted fragments of dist-newstyle/build. This works, but:
it's clumsy
it's not discoverable
it's probably not comprehensively cleaning the package (I have no idea if it gets all the files!)
I think it would be nice to provide a per package/component cabal clean, and hopefully it would just be a matter of listing all the relevant files and deleting them.
Reacted by George Thomas, Yura, Shivaraj B H, Momo and Jean-Charles Quillet
I guess we'd need to delete the package or component files and the common files. The trouble is identifying those, in particular if they are not generated with cabal build but only with some other commands or with some specific options.
What does cabal clean do exactly? Only remove dist-newstyle or anything else?
-s, --save-config Save configuration, only remove build artifacts
I wonder what's 'configuration' and 'artifacts' and if there is anything more. Code-diving would help.
As far as I can tell, that flag is just being ignored, but the code path should delete only dist-newstyle/build which is still not fine-grained enough for the proposed feature.
May it be that 'configuration' is only cabal.project.local, which is not removed by cabal clean and that's why cabal clean never removes configuration in the new v2- world? If so, we should mark the -s flag "deprecated; configuration is always saved now" once v1- commands are removed.
However, if 'configuration' is cabal.project.local and artifacts are dist-newstyle/build, is there anything else? E.g., any kind of caches? E.g., when downloading packages form repos?
I think currently cabal clean considers everything in dist-newstyle/build as build artefacts (which makes sense) and other files, e.g. dist-newstyle/cache is configuration.
However, the help message from Setup.hs actually tells us roughly that:
-s --save-configure Do not remove the configuration file (dist/setup-config)
during cleaning. Saves need to reconfigure.
Not exactly the same flag but looks similar. Maybe --save-config is a remnant from Setup.hs that doesn't make much sense in cabal v2 world? I would argue at least in that sense.
Regarding the issue, I think there are two ways of tackling this:
Calling Setup.hs clean for each component listed on the command line
Basically call the functions from Cabal manually (assuming there are no Buildhooks) with the right parameters Just checked, there is a postClean Hook. Only method one remains.
cabal clean serves as a simple workaround for lot of problems hard to fix properly. Having a more fine grained cleaning would make the workaround more attractive
Activity
Mikolaj commentedon Aug 4, 2021
I guess we'd need to delete the package or component files and the common files. The trouble is identifying those, in particular if they are not generated with
cabal buildbut only with some other commands or with some specific options.What does
cabal cleando exactly? Only removedist-newstyleor anything else?Mikolaj commentedon Aug 4, 2021
I see there is option
I wonder what's 'configuration' and 'artifacts' and if there is anything more. Code-diving would help.
fendor commentedon Aug 4, 2021
As far as I can tell, that flag is just being ignored, but the code path should delete only
dist-newstyle/buildwhich is still not fine-grained enough for the proposed feature.Mikolaj commentedon Aug 4, 2021
OK, so we discovered a bug as well.
fendor commentedon Aug 4, 2021
Looks rather intentional to me:
cabal/cabal-install/src/Distribution/Client/CmdClean.hs
Line 72 in 769e4ed
Mikolaj commentedon Aug 4, 2021
May it be that 'configuration' is only
cabal.project.local, which is not removed bycabal cleanand that's whycabal cleannever removes configuration in the new v2- world? If so, we should mark the-sflag "deprecated; configuration is always saved now" once v1- commands are removed.However, if 'configuration' is
cabal.project.localand artifacts aredist-newstyle/build, is there anything else? E.g., any kind of caches? E.g., when downloading packages form repos?fendor commentedon Aug 4, 2021
I think currently
cabal cleanconsiders everything indist-newstyle/buildas build artefacts (which makes sense) and other files, e.g.dist-newstyle/cacheis configuration.However, the help message from
Setup.hsactually tells us roughly that:Not exactly the same flag but looks similar. Maybe
--save-configis a remnant fromSetup.hsthat doesn't make much sense in cabal v2 world? I would argue at least in that sense.Regarding the issue, I think there are two ways of tackling this:
Basically call the functions fromJust checked, there is aCabalmanually (assuming there are no Buildhooks) with the right parameterspostCleanHook. Only method one remains.TeofilC commentedon Dec 8, 2021
As I mentioned on #7857, I'd be interested in trying to implement this.
On the other ticket:
bacchanalia commentedon Jan 2, 2022
@TeofilC #7851 has been merged, so you should be clear if you want to work on this.
[-]Per package/component `cabal clean`[/-][+]Per package/component `cabal clean` (add support for targets)[/+]jneira commentedon May 11, 2022
cabal cleanserves as a simple workaround for lot of problems hard to fix properly. Having a more fine grained cleaning would make the workaround more attractive