conan-io / docs

conan.io reStructuredText documentation
http://docs.conan.io
MIT License
104 stars 352 forks source link

[bug] Conan download_cache is not working on conan 2 #3276

Open igadmg opened 1 year ago

igadmg commented 1 year ago

Environment details

have setup conan download cache in global.conf but it does not work

My setup core.cache:storage_path=f:/.conan core.download:download_cache=f:/.conan/.cache

but files are redownloaded every conan create rerun

Steps to reproduce

No response

Logs

No response

memsharded commented 1 year ago

Hi @yatagarasu25

Thanks for your report. Could you please clarify which files are being re-downloaded?

For clarification the file download cache has 2 different confs:

conan config list | grep cache
core.cache:storage_path: Absolute path where the packages and database are stored
core.download:download_cache: Define path to a file download cache
tools.files.download:download_cache: Define the cache folder to store downloads from files.download()/get()

Is it possible that you are missing the second one?

igadmg commented 1 year ago

Thanks, I completely missed tools.files.download:download_cache It is sort of working now, yet still sometime files are cached sometimes they don't. Looks like that depends if sources are read form yaml or url is passed directly from coananfile.py

memsharded commented 1 year ago

It is sort of working now, yet still sometime files are cached sometimes they don't. Looks like that depends if sources are read form yaml or url is passed directly from coananfile.py

The difference could be if the yaml provide md5/sha1 checksums or not. Only files that provide a checksum are cached in the fileDownloadCache

jwillikers commented 1 year ago

I think it would help if this feature was better documented. If ~ isn't going to be expanded, the documentation should say so and document how to use a cache configured in the user's home directory. Many users are probably going to want to put this somewhere in there home directory, like in ~/.cache. I used the following in global.conf to get this working in Conan 1.60.0.

core.download:download_cache = {{ os.path.join(os.path.expanduser('~'), ".cache", "conan", "download") }}
tools.files.download:download_cache = {{ os.path.join(os.path.expanduser('~'), ".cache", "conan", "download") }}
memsharded commented 1 year ago

This has changed in Conan 2.0, that by default will use a download cache inside the Conan cache. We are testing the new features in ConanCenter, and hopefully it will be publicly launched in 2.0.6.