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

Error: missing lockfile prevents dependency installation #1308

Closed
xinyu-hou opened this issue Nov 15, 2024 · 4 comments
Closed

Error: missing lockfile prevents dependency installation #1308

xinyu-hou opened this issue Nov 15, 2024 · 4 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@xinyu-hou
Copy link

Hi,

I am encountering an issue with the cypress-io/github-action in my GitHub Actions script. I have chosen not to commit the "package-lock.json" file in my GitHub repository, as I can generate one using the "npm install" command.

However, this seems to cause a problem when I attempt to use the cypress-io/github-action. Below is my current GitHub Actions script:

name: Cypress Component Tests

on:
  push:
  workflow_dispatch:

jobs:
  cypress-component-tests:
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository code
        uses: actions/checkout@v4
      - name: Run Cypress component tests
        uses: cypress-io/github-action@v6
        with:
          install-command: npm install
          component: true

Here is the error message I encountered:

Error: Action failed. Missing package manager lockfile. Expecting one of package-lock.json (npm), pnpm-lock.yaml (pnpm) or yarn.lock (yarn) in working-directory /runner/_work/xinyu-cypress-action-investigation/xinyu-cypress-action-investigation

It appears that despite specifying the install-command, the cypress-io/github-action does not install the dependencies before running the component tests. I am curious if a "package-lock.json" file is indeed required to use the cypress-io/github-action.

Thank you for your assistance!

@MikeMcC399 MikeMcC399 added the documentation Improvements or additions to documentation label Nov 16, 2024
@MikeMcC399 MikeMcC399 self-assigned this Nov 16, 2024
@MikeMcC399
Copy link
Collaborator

@xinyu-hou

The default use of cypress-io/github-action requires a package manager lockfile to be present. This is used to install dependencies and to key caches.

According to the npm documentation, package-lock.json is intended to be committed into source repositories.

If you do not want to follow the recommendations of the npm documentation, and do not commit a package-lock.json file, then you must install dependencies before using cypress-io/github-action and then disable installation in the action:

uses: cypress-io/github-action@v6
with:
  install: false

@MikeMcC399
Copy link
Collaborator

@xinyu-hou
Copy link
Author

@MikeMcC399

Thank you for the clarification! I appreciate it!

@MikeMcC399
Copy link
Collaborator

@xinyu-hou

Thank you for the clarification! I appreciate it!

You uncovered a gap in the documentation and so the section Custom install command is now made to cover this situation.

Thank you also for your report! I am going to close this issue now as it has been resolved through the documentation update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants