How do I change the GHCup metadata cache timeout and/or make the updates quieter?

I have seen this quite a few times today:
tc$ ghcup list -t cabal
[ Info ] downloading: https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-0.0.9.yaml as file /home/cjs/.ghcup/c
ache/ghcup-0.0.9.yaml % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
Tool Version Tags Notes
✗ cabal 2.4.1.0
✗ cabal 3.0.0.0
...
In fact, since I'm using ghcup a fair amount while testing some things, I am seeing it every five minutes or so.
The entirety of the documentation on this seems to be:
Metadata cache
The metadata files (also see github.com/haskell/ghcup-metadata) have a 5 minutes cache per default depending on the last access time of the file. That means if you run ghcup list 10 times in a row, only the first time will trigger a download attempt.
Is there any way to change this cache timeout to something much longer? To me it seems reasonable just to check once a day, or once every few hours at most. After all, how often are new versions of GHC/Cabal/HLS/Stack released? (Or is there something I'm missing here that wants faster updates? The ghcup-metadata
repo can easily go a couple of weeks without an update.
Answer
The Configuration section of the documentation explains that there is a configuration file. The file syntax is not documented on the site itself (which is why searching the site pages won't find the meta-cache
config option), but it directs you to a commented sample file in the source code. Here is the relevant extract:
# The caching for the metadata files containing download info, depending on last access time
# of the file. These usually are in '~/.ghcup/cache/ghcup-<ver>.yaml'.
meta-cache: 300 # in seconds
Thus, adding meta-cache: 86400
to your ~/.ghcup/config.yaml
will change the timeout to one day.
Note that later entries override earlier entries (this is not documented), so if you leave the default meta-cache: null
that was placed in that file when it was installed, your meta-cache:
entry must be in the file after that line in order to override it.
Enjoyed this question?
Check out more content on our blog or follow us on social media.
Browse more questions