I have a cache, for two NPM installs…one in the root directory of my project, and one in a child directory. We have two package-lock.json files that we are checksumming as part of our key. The cache creation shows that it is including both paths, and the cache restoration also shows both paths. However, it appears that only the root path is actually being restored, and the child path is not.
Example (hashes and explicit path names removed):
INITIAL JOB: lint-test
Creating cache archive... Uploading cache archive... Stored Cache to deps-v3-arch1-linux-amd64-6_85-####hashof_root_package-lock.json-####hashof_child_package-lock.json * /home/circleci/project/node_modules * /home/circleci/project/apps/child/node_modules
SECONDARY JOB: cypress/run (from orb firstname.lastname@example.org)
Found a cache from build XYZ at deps-v3-arch1-linux-amd64-6_85-####hashof_root_package-lock.json-####hashof_child_package-lock.json Size: 182 MB Cached paths: * /home/circleci/project/node_modules * /home/circleci/project/apps/child/node_modules Downloading cache archive... Validating cache... Unarchiving cache...
The cypress job is failing, as when we try to start the child app, it fails trying to find dependencies (packages to import, typescript). I SSHed into the cypress/run container, and did an
ls on the apps/child directory. There is no
node_modules directory in there. There is a
node_modules directory in the root of the project, though. It appears that restoration of the child app node_modules simply did not occur…
I also SSHed into the container for the initial job, and did
ls on the apps/child directory. There IS a
node_modules directory in there.
Another potential issue here is…we have no way to really know for sure what is actually in a cache. It does not appear that there is anything like a cache browser or anything like that to check if a cache actually contains what you tried to put into it…so I am honestly not sure if the cache contains the child node_modules or not. I assume it does, as it is listed in the directories that were included in the cache, and there are no errors reported about its restoration. The only thing I can know for sure is that the child node_modules definitely does not exist on the file system of the container the cache is being restored to…