Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixing cache load step breaking when no lock file is detected #200

Conversation

dotkas
Copy link
Contributor

@dotkas dotkas commented Dec 7, 2023

If your project does not contain any lockfile at all, this logic falls through and does not copy anything to $TARGET_DIR/node-project-lockfile:

# Link corresponding lock file to a temporary file used by cache commands
if [ -f "package-lock.json" ]; then
echo "Found package-lock.json file, assuming lockfile"
cp package-lock.json $TARGET_DIR/node-project-lockfile
elif [ -f "npm-shrinkwrap.json" ]; then
echo "Found npm-shrinkwrap.json file, assuming lockfile"
cp npm-shrinkwrap.json $TARGET_DIR/node-project-lockfile
elif [ -f "yarn.lock" ]; then
echo "Found yarn.lock file, assuming lockfile"
cp yarn.lock $TARGET_DIR/node-project-lockfile
fi

However, if you run this without with-cache: false, this step fails:

- node-deps-{{ arch }}-<<parameters.cache-version>>-<<#parameters.include-branch-in-cache-key>>{{ .Branch }}-<</parameters.include-branch-in-cache-key>><<^parameters.cache-only-lockfile>>{{ checksum "/tmp/node-project-package.json" }}-<</parameters.cache-only-lockfile>>{{ checksum "/tmp/node-project-lockfile" }}

As:

error computing cache key: template: cacheKey:1:41: executing "cacheKey" at <checksum "/tmp/node-project-lockfile">: error calling checksum: open /tmp/node-project-lockfile: no such file or directory

Expected behavior:

Caching step should complete without a lockfile present.

@dotkas dotkas requested a review from a team as a code owner December 7, 2023 11:05
@orb-publisher
Copy link

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/node?version=dev:e87e1167357227b0841db7bb5b8f56c56858aff0

@KyleTryon
Copy link
Contributor

Thank you for sending in this PR 👍

We will need to make another update to get these tests passing (not related to your changes). We'll have that here asap and then update this branch and run the tests again

Copy link
Contributor

@EricRibeiro EricRibeiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! 🙇

@EricRibeiro EricRibeiro merged commit d25a565 into CircleCI-Public:master Dec 14, 2023
2 checks passed
@dotkas dotkas deleted the dotkas/fix-cache-error-on-no-lockfile branch January 4, 2024 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants