jsmrcaga / action-netlify-deploy

MIT License
102 stars 32 forks source link

EACCES: permission denied during npm install #34

Closed paurakhsharma closed 2 years ago

paurakhsharma commented 2 years ago

This happens once in a while. I haven't been able to reproduce it consistently.

This is now my workflow file looks like.

name: 'Deploy to Netlify'

on:
  push:
    branches:
      - main

jobs:
  deploy:
    name: 'Deploy to Netlify'
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Deploy to Netlify
        uses: jsmrcaga/action-netlify-deploy@v1.8.0
        with:
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
          NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
          NETLIFY_DEPLOY_MESSAGE: 'Prod deploy v${{ github.ref }}'
          NETLIFY_DEPLOY_TO_PROD: true
          build_directory: public

And my npm run build script does npm install

This is the log I get in github actions. ``` npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated npm WARN deprecated statsd-client@0.4.7: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info. npm WARN deprecated flatten@1.0.3: flatten is deprecated in favor of utility frameworks such as lodash. npm WARN deprecated node-pre-gyp@0.13.0: Please upgrade to @mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped package will recieve updates in the future added 1404 packages, and audited 1405 packages in 1m 157 packages are looking for funding run `npm fund` for details 10 vulnerabilities (1 moderate, 9 high) To address issues that do not require attention, run: npm audit fix To address all issues possible (including breaking changes), run: npm audit fix --force Some issues need review, and may require choosing a different dependency. Run `npm audit` for details. up to date, audited 1 package in 319ms found 0 vulnerabilities > nepali_christian_songs@1.0.0 build > cd functions && npm install npm ERR! code EACCES npm ERR! syscall mkdir npm ERR! path /github/home/.npm/_cacache/content-v2/sha1/1b/0a 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 1001:[12](https://github.com/paurakhsharma/nepali_christian_songs/runs/6878223643?check_suite_focus=true#step:4:13)1 "/github/home/.npm" npm ERR! A complete log of this run can be found in: npm ERR! /github/home/.npm/_logs/2022-06-14T10_[13](https://github.com/paurakhsharma/nepali_christian_songs/runs/6878223643?check_suite_focus=true#step:4:14)_07_4[25](https://github.com/paurakhsharma/nepali_christian_songs/runs/6878223643?check_suite_focus=true#step:4:26)Z-debug-0.log ```
jsmrcaga commented 2 years ago

Hi @paurakhsharma !

Thanks for the issue.

From what I can see in the logs there is:

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.

however this action is supposed to use node-current, so 18 at the moment. The bug should not be happening in your case.

Does your workflow run after a build workflow? If so, are you using a specific node version? If that's the case maybe updating node/npm in that workflow could solve the issue. Let us know!

paurakhsharma commented 2 years ago

No this is the only build workflow I have. I am serving static files via Netlify but I have some cloud functions. I need to run npm build only to install the dependencies for the cloud functions.

This is my root package.json ``` { "name": "nepali_christian_songs", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "build": "cd functions && npm install" }, "repository": { "type": "git", "url": "git+https://github.com/paurakhsharma/nepali_christian_songs.git" }, "keywords": [], "author": "", "license": "ISC", "bugs": { "url": "https://github.com/paurakhsharma/nepali_christian_songs/issues" }, "homepage": "https://github.com/paurakhsharma/nepali_christian_songs#readme" } ```
And this is what my functions/package.json looks like. ``` { "name": "functions", "version": "1.0.0", "description": "", "main": "index.js", "scripts": {}, "keywords": [], "author": "", "license": "ISC", "dependencies": { "@google-cloud/firestore": "^5.0.2", "@netlify/functions": "^0.10.0", "@types/node": "^14.0.0", "firebase-admin": "^10.0.1", "octokit": "^1.7.1", "typescript": "^4.0.0" } } ```
jsmrcaga commented 2 years ago

Hi @paurakhsharma

Could you try using actions/setup-node to setup a newer version of node before running npm build? If your project supports node latest we can try (18.3 i believe), otherwise we can go for lts (16.15.1 i believe)

paurakhsharma commented 2 years ago

Thank you so much. Looks like it is fixed for now. But it happens infrequently so I cannot be sure for now. I will re-open the issue if it happens again and I get the hint that it is related to this GitHub action.

jsmrcaga commented 2 years ago

Great! Keep up up to date!