GitHub ESLint action failing with "Permission Denied"

Viewed 895

I'm writing a CI workflow (GitHub actions), and it seems that eslint is failing with "Permission Denied" code 126. I can't seem to fix it.

Can someone explain why ESlint is failing with permission denied? If so, is there a solution?

Here's a link to the pr where it's failing.

1 Answers

If a GitHub action fails with Permission Denied there are two possibilities:

1. You are trying to run a command that requires elevated privileges

To solve this just prefix sudo. E.g. npx eslint > sudo npx eslint. The GitHub Docs specify:

The Linux and macOS virtual machines both run using passwordless sudo.

2. A shell script does not have the execute filesystem permission set

If you have a unix/bash shell handy, you can change that with:

chmod +x ./.github/scripts/xxx.sh

If not, you can tell git to add the permission with this command:

git update-index --chmod=+x ./.github/scripts/xxx.sh

update-index is similar to add in that it adds the change to the index, so you'll have to commit and push as usual.

Related