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

ENOENT: no such file or directory during self-install #108

Closed
thathurtabit opened this issue Jan 13, 2024 · 6 comments
Closed

ENOENT: no such file or directory during self-install #108

thathurtabit opened this issue Jan 13, 2024 · 6 comments

Comments

@thathurtabit
Copy link

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'
@oakhtar147
Copy link

oakhtar147 commented Jan 16, 2024

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.

@thathurtabit
Copy link
Author

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.

@oakhtar147
Copy link

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!

@thathurtabit
Copy link
Author

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.

@arcs-
Copy link

arcs- commented Feb 21, 2024

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

@thathurtabit
Copy link
Author

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

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

No branches or pull requests

3 participants