action-setup icon indicating copy to clipboard operation
action-setup copied to clipboard

ENOENT: no such file or directory during self-install

Open thathurtabit opened this issue 1 year ago • 4 comments

Admittedly my knowledge of github-actions and pnpm is not great, and I'm running into this issue during the pnpm/action-setup stage.

For some reason - likely down to missing settings - it's doubling the app name, i.e. glssry.org/glssry.org/package.json I'm not sure why that is.

Run pnpm/[email protected]
Running self-installer...
  [Error: ENOENT: no such file or directory, open '/home/runner/work/glssry.org/glssry.org/package.json'] {
    errno: -2,
    code: 'ENOENT',
    syscall: 'open',
    path: '/home/runner/work/glssry.org/glssry.org/package.json'
  }
  Error: Error: ENOENT: no such file or directory, open '/home/runner/work/glssry.org/glssry.org/package.json'

thathurtabit avatar Jan 13 '24 11:01 thathurtabit

Assuming you have something like this in the step:

 - name: Install pnpm
   uses: pnpm/action-setup@v2

You need to provide a pnpm version. According to the docs:

Version of pnpm to install.
Optional when there is a packageManager field in the package.json.
otherwise, this field is required It supports npm versioning scheme, it could be an exact version (such as 6.24.1), or a version range (such as 6, 6.x.x, 6.24.x, ^6.24.1, *, etc.), or latest.

So either specify a version or a package_json_file:

- name: Install pnpm
  uses: pnpm/action-setup@v2
  with:
    version: ^8.14.1
    package_json_file: path/to/package.json # Alternatively, specify path to `package.json` that has `packageManager` field.

The packageManager alternative is buggy due to non-standard convention followed by pnpm. See more here.

This will fix your error if it's due to the version. If not, I cannot help without additional information or reproduction.

oakhtar147 avatar Jan 16 '24 11:01 oakhtar147

Hi, thanks for the reply, sorry I should have given more info:

So my github-action (called preview.yaml) has:

    steps:
    - uses: pnpm/action-setup@v2
      name: Install pnpm
      with:
        version: ^8.14.1

My package.json has:

  "packageManager": "[email protected]",

I get slightly different error messages between running the actions locally with act and when deployed to github

  • notably the path is different (github doubles the glssry.org part of the path):

act (local)


[Vercel Production Deployment/Deploy-Production] ⭐ Run Main pnpm/[email protected]
[Vercel Production Deployment/Deploy-Production]   🐳  docker cp src=/Users/Stephen.Fairbanks/.cache/act/[email protected]/ dst=/var/run/act/actions/[email protected]/
[Vercel Production Deployment/Deploy-Production]   🐳  docker exec cmd=[node /var/run/act/actions/[email protected]/dist/index.js] user= workdir=
[Vercel Production Deployment/Deploy-Production]   ❓  ::group::Running self-installer...
| [Error: ENOENT: no such file or directory, open '/Users/Stephen.Fairbanks/Repos/glssry.org/package.json'] {
|   errno: -2,
|   code: 'ENOENT',
|   syscall: 'open',
|   path: '/Users/Stephen.Fairbanks/Repos/glssry.org/package.json'
| }
[Vercel Production Deployment/Deploy-Production]   ❗  ::error::Error: ENOENT: no such file or directory, open '/Users/Stephen.Fairbanks/Repos/glssry.org/package.json'
[Vercel Production Deployment/Deploy-Production]   ❌  Failure - Main pnpm/[email protected]
[Vercel Production Deployment/Deploy-Production] exitcode '1': failure

Github:

Run pnpm/[email protected]
Running self-installer...
  [Error: ENOENT: no such file or directory, open '/home/runner/work/glssry.org/glssry.org/package.json'] {
    errno: -2,
    code: 'ENOENT',
    syscall: 'open',
    path: '/home/runner/work/glssry.org/glssry.org/package.json'
  }
  Error: Error: ENOENT: no such file or directory, open '/home/runner/work/glssry.org/glssry.org/package.json'

I'd guess it's something simple I'm missing.

thathurtabit avatar Jan 16 '24 13:01 thathurtabit

My best bet is sticking to one pnpm version, either defined in package.json or within the workflow file.

I'm not aware of your directory structure, but the action also expects a package_json_file filepath incase you are running a monorepo setup for example.

My personal experience was that I faced errors defining the version in packageManager field in package.json due to the non-standard convention this action expects, so I stuck with defining it in the workflow file. And it worked without problems.

Regarding the double directory issue, I did get that as well in error logs. I am not sure if this is something for maintainers of this repo to fix, but here's another issue that might help you.

Hope this helps!

oakhtar147 avatar Jan 17 '24 09:01 oakhtar147

Thanks for your reply here, but I don't know if I can find a way to solve this.

Just for clarity on my folder structure (I'm running a Next app, but not a monorepo):

   .github
     - workflows
     -- preview.yaml
     -- production.yaml
   ...
   package.json

Running act locally to test the actions, I get the error:

Run Main pnpm/[email protected]
[Vercel Production Deployment/Deploy-Production]   🐳  docker cp src=/Users/Stephen.Fairbanks/.cache/act/[email protected]/ dst=/var/run/act/actions/[email protected]/
[Vercel Production Deployment/Deploy-Production]   🐳  docker exec cmd=[node /var/run/act/actions/[email protected]/dist/index.js] user= workdir=
[Vercel Production Deployment/Deploy-Production]   ❓  ::group::Running self-installer...
| [Error: ENOENT: no such file or directory, open '/Users/Stephen.Fairbanks/Repos/glssry.org/package.json'] {
|   errno: -2,
|   code: 'ENOENT',
|   syscall: 'open',
|   path: '/Users/Stephen.Fairbanks/Repos/glssry.org/package.json'
| }

...
 ERR_PNPM_NO_PKG_MANIFEST  No package.json found in /Users/Stephen.Fairbanks/Repos/glssry.org

If I click the path in my terminal, it takes me directly to the package.json file, so I don't know why the runner can't find it.

The issue you kindly provided doesn't seem to have a resolution unfortunately. I might just have to give up and go back to npm.

thathurtabit avatar Jan 17 '24 10:01 thathurtabit

Are you missing the uses: actions/checkout@v4 step in front of it? This would result in you not having the package.json.

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: pnpm/action-setup@v3

arcs- avatar Feb 21 '24 16:02 arcs-

This was it @arcs- ! Thank you for taking a look. I clearly need to understand how github actions work. Thanks very much.

thathurtabit avatar Feb 21 '24 17:02 thathurtabit