Skip to content
Latchkey

GitLab CI "cache:key:files config requires at least one file"

cache:key:files derives a cache key from the SHA of up to two files, so the cache invalidates when those lockfiles change. It must list at least one and at most two files.

What this error means

CI lint rejects the cache config, stating cache:key:files requires at least one file, or that too many files were provided.

gitlab-ci
This GitLab CI configuration is invalid:
jobs:build:cache:key:files config requires at least one and no more than two files

Common causes

Empty files list

A files: [] or a files: key with no entries provides nothing to hash.

More than two files listed

cache:key:files accepts a maximum of two file paths.

Listed file path does not exist

If neither listed file exists, GitLab falls back to a default key but the config intent is broken.

How to fix it

List one or two real lockfiles

Point cache:key:files at the lockfiles that should invalidate the cache.

.gitlab-ci.yml
build:
  cache:
    key:
      files:
        - package-lock.json
        - yarn.lock
    paths:
      - node_modules/

How to prevent it

  • Always list at least one existing lockfile under cache:key:files.
  • Keep the list to two files maximum.
  • Pair cache:key:files with a prefix if you share caches across jobs.

Frequently asked questions

What causes ""cache:key:files" empty"?
A files: [] or a files: key with no entries provides nothing to hash.
How do I fix "cache:key:files" empty?
Point cache:key:files at the lockfiles that should invalidate the cache.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card