rattler-build icon indicating copy to clipboard operation
rattler-build copied to clipboard

Support removing the build cache from the output directory

Open vyasr opened this issue 10 months ago • 3 comments

Currently when you build a recipe using the cache key, the cache is a subdirectory of the output directory. As a result, the contents of the cache are also included into the build. I can see how there might be reasons to preserve a cache across builds, for example if you specify --no-build-id you could reuse the build directory for packages with compiled components. However, for actually publishing packages I don't think you want to retain the cache because it bloats packages unnecessarily. It would be nice if there could be a CLI option to remove the cache (perhaps on by default? I assume most interactive usage of rattler-build is short-lived for testing and the more common use-case is in CI jobs that build and publish packages). For now, we are working around this by manually removing the cache directory in our build script.

vyasr avatar Feb 11 '25 20:02 vyasr

This makes a lot of sense.

wolfv avatar Feb 12 '25 07:02 wolfv

I just re-read this issue after a while and I think I am a little confused about some of the words. The contents of the cache should not "directly" make it into the package (only if they are selected / installed). So in theory there should never be additional "bloat" from the cache.

It is true that we keep the cache results in the output/bld_cache folder, and we don't remove it after the build has finished. This can and should be improved so that we only keep the cache under certain circumstances (such as if the the --keep-build flag is true).

wolfv avatar May 12 '25 08:05 wolfv

I apologize, I think in between when I first encountered the problem and when I wrote up this issue I forgot the exact problem and developed a misunderstanding of what we needed. It seems that when writing this issue I had in my head that the build cache was actually winding up inside the built packages from a previous discussion, but that was purely a misunderstanding on my part and is not what I observe. You are correct, the cache stays in the output directory but it does not end up in the packages. Your follow-up suggestion (removing the cache from the output directory unless requested) is indeed what I had originally wanted to ask for and would resolve the issues that we encountered that led to this (we preserve the output directory in Github Actions artifact stores in between jobs for testing before we upload anything to a final package index).

vyasr avatar May 13 '25 01:05 vyasr