Using Lychee in the same directory with changing --remap options will fail to invalidate the cache when --remap is changed. I've run into this bug when testing remaps to try and write a correct remap expression.
I think a contributing factor to this bug is the .lycheecache entries are keyed by the original URL, before any remaps are applied.
These commands should demonstrate the problem.
echo 'https://google.com' > a.md
# run once. this succeeds
lychee a.md --cache -v
# introduce remap which should cause failure. still succeeds.
lychee a.md --cache -v --remap "https://google.com https://google.com/nonexistent"
cat .lycheecache
# try in other direction (with remap initially, then removing it)
rm .lycheecache
lychee a.md --cache -v --remap "https://google.com https://google.com/nonexistent"
# incorrectly fails
lychee a.md --cache -v
cat .lycheecache
An example log of the commands is below, with lychee 0.20.0.
$ echo 'https://google.com' > a.md
$ lychee a.md --cache -v
[200] https://google.com/
🔍 1 Total (in 0s) ✅ 1 OK 🚫 0 Errors
$ lychee a.md --cache -v --remap "https://google.com https://google.com/nonexistent"
[INFO ] Cache is recent (age: 40s, max age: 1d 0h 0m 0s). Using.
[200] https://google.com/ | OK (cached)
🔍 1 Total (in 0s) ✅ 1 OK 🚫 0 Errors
$ cat .lycheecache
https://google.com/,200,1756040828
$ rm .lycheecache
$ lychee a.md --cache -v --remap "https://google.com https://google.com/nonexistent"
[404] https://google.com/nonexistent/ | Rejected status code (this depends on your "accept" configuration): Not Found
Issues found in 1 input. Find details below.
[a.md]:
[404] https://google.com/nonexistent/ | Rejected status code (this depends on your "accept" configuration): Not Found
🔍 1 Total (in 0s) ✅ 0 OK 🚫 1 Error
$ lychee a.md --cache -v
[INFO ] Cache is recent (age: 1m 26s, max age: 1d 0h 0m 0s). Using.
[404] https://google.com/ | Error (cached)
Issues found in 1 input. Find details below.
[a.md]:
[404] https://google.com/ | Error (cached)
🔍 1 Total (in 0s) ✅ 0 OK 🚫 1 Error
$ cat .lycheecache
https://google.com/,404,1756040883
There might also be similar bugs for other flags which affect URL resolution. However, since the cache is only used for remote URLs (I think?), --fallback-extensions and --index-files do not seem to be affected by this bug.
Using Lychee in the same directory with changing --remap options will fail to invalidate the cache when --remap is changed. I've run into this bug when testing remaps to try and write a correct remap expression.
I think a contributing factor to this bug is the .lycheecache entries are keyed by the original URL, before any remaps are applied.
These commands should demonstrate the problem.
An example log of the commands is below, with lychee 0.20.0.
There might also be similar bugs for other flags which affect URL resolution. However, since the cache is only used for remote URLs (I think?),
--fallback-extensionsand--index-filesdo not seem to be affected by this bug.