Skip to content

fix: Move schema cache to platform-appropriate user directory - #4571

Merged
kddejong merged 2 commits into
aws-cloudformation:mainfrom
kddejong:fix/configurable-schema-cache-dir
Jul 6, 2026
Merged

fix: Move schema cache to platform-appropriate user directory#4571
kddejong merged 2 commits into
aws-cloudformation:mainfrom
kddejong:fix/configurable-schema-cache-dir

Conversation

@kddejong

@kddejong kddejong commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Schemas are now downloaded to a user-writable cache directory instead of the package install location
  • Uses AWS-standard platform paths:
    • Linux: ~/.cache/aws/cfn-lint/schemas/
    • macOS: ~/Library/Caches/aws/cfn-lint/schemas/
    • Windows: %LOCALAPPDATA%\aws\cfn-lint\schemas\
  • Respects XDG_CACHE_HOME on Linux when set

Why

Writing into the package install directory fails on immutable/read-only installs (Nix, distro packages, containers) and can also fail in pre-commit environments. Moving to a user-writable cache location resolves both scenarios.

Auto-download on first run still works — if the cache dir is empty, cfn-lint downloads schemas automatically.

Fixes #4568
Fixes #4563

Test plan

  • Verify cfn-lint -u downloads to the new cache location
  • Verify first-run auto-download works when cache is empty
  • Verify read-only package installs (Nix) no longer error
  • Verify pre-commit usage works without manual cfn-lint -u

Schemas are now downloaded to a user-writable cache directory instead of
the package install location, fixing Permission denied errors on
immutable installs (Nix, distro packages) and pre-commit environments.

Paths follow AWS-standard conventions:
  Linux:   ~/.cache/aws/cfn-lint/schemas/
  macOS:   ~/Library/Caches/aws/cfn-lint/schemas/
  Windows: %LOCALAPPDATA%/aws/cfn-lint/schemas/

Respects XDG_CACHE_HOME on Linux when set.

Fixes aws-cloudformation#4568
Fixes aws-cloudformation#4563
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.41%. Comparing base (2348741) to head (6bccec6).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4571   +/-   ##
=======================================
  Coverage   94.40%   94.41%           
=======================================
  Files         429      429           
  Lines       15048    15056    +8     
  Branches     2910     2911    +1     
=======================================
+ Hits        14206    14215    +9     
  Misses        461      461           
+ Partials      381      380    -1     
Flag Coverage Δ
unittests 94.41% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kddejong
kddejong merged commit 01fda43 into aws-cloudformation:main Jul 6, 2026
21 checks passed
@kddejong
kddejong deleted the fix/configurable-schema-cache-dir branch July 6, 2026 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant