Shopify / theme-check-action

Run shopify/theme-check on GitHub pull requests
Other
38 stars 14 forks source link

The process '/usr/bin/npm' failed with exit code 243 #34

Closed andershagbard closed 7 months ago

andershagbard commented 7 months ago

We are trying to set up this function on a self-hosted runner. Not sure if this issue is on our end, or an issue with your action.

/usr/bin/npm install --no-package-lock --no-save @shopify/cli @shopify/theme
npm ERR! code EACCES
npm ERR! syscall open
npm ERR! path /home/runner/.npm/_cacache/tmp/5dfc2e4f
npm ERR! errno -13
npm ERR! 
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR! 
npm ERR! To permanently fix this problem, please run:
npm ERR!   sudo chown -R [10](JOB_URL#step:4:11)00:1000 "/home/runner/.npm"

npm ERR! Log files were not written due to an error writing to the directory: /home/runner/.npm/_logs
npm ERR! You can rerun the command with `--loglevel=verbose` to see the logs in your terminal
Error: The process '/usr/bin/npm' failed with exit code 243
charlespwd commented 7 months ago

aye aye aye. Since @shopify/theme-check-action@v2, we're not doing docker builds anymore. In setup.ts, we do a pretty basic npm install.

Your error message is related to problems with root-owned files being in there. Without more context I can't tell why that would be a problem. Maybe your self-hosted runner needs to setup a different cache folder? Are you using @actions/setup-node@v4?

andershagbard commented 7 months ago

We are using setup-node@v4 with pnpm cache.

uses: actions/setup-node@v4
with:
  cache: 'pnpm'

Our runner is Dockerfile looks like this:

FROM summerwind/actions-runner:latest

USER root

RUN curl -sL https://deb.nodesource.com/setup_20.x | bash - 
RUN apt-get install -y nodejs
RUN npm install --global yarn
RUN npm install --global pnpm

USER runner

It installs node 20 on root, and installs yarn and pnpm globally.

charlespwd commented 7 months ago

That's probably where the problem lies. npm install --global yarn as root will populate your global folder with root-owned files. This runner (theme-check-action) then tries to npm install @shopify/cli @shopify/theme, but not as root and throws a EACCESS error (Permission denied).

Looks like a chown or changing the user that installs npm/yarn to be non-root would solve your problem.