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

[BUG] prettier: command not found #114

Closed
semseysandor opened this issue Feb 18, 2023 · 3 comments
Closed

[BUG] prettier: command not found #114

semseysandor opened this issue Feb 18, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@semseysandor
Copy link

What exactly happened?
Steps to reproduce the behavior:

  1. Run prettier_action:
    - name: Check code-style
      uses: creyD/prettier_action@v4.2
      with:
        dry: true
        prettier_options: --check **/*.{md,yml}
    
  2. Step failed
    Installing prettier...
    Prettifying files...
    /home/runner/work/_actions/creyD/prettier_action/v4.2/entrypoint.sh: line 74: prettier: command not found
    Files:
    Problem running prettier with --check **/*.{md,yml}
    Error: Process completed with exit code 1.
    

What should've happened?
Step should succeed or prettier should run at least.

Note

I've did some debugging:

  • it seems prettier is not found because $PATH is off:
    echo PATH=$PATH
    PATH=Unknown command: "bin"
    
    To see a list of supported npm commands, run:
      npm help:/home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
    
  • running npm help confirm npm bin is not available
    npm <command>
    
    Usage:
    
    npm install        install all the dependencies in your project
    npm install <foo>  add the <foo> dependency to your project
    npm test           run this project's tests
    npm run <foo>      run the script named <foo>
    npm <command> -h   quick help on <command>
    npm -l             display usage info for all commands
    npm help <term>    search for help on <term>
    npm help npm       more involved overview
    
    All commands:
    
        access, adduser, audit, bugs, cache, ci, completion,
        config, dedupe, deprecate, diff, dist-tag, docs, doctor,
        edit, exec, explain, explore, find-dupes, fund, get, help,
        hook, init, install, install-ci-test, install-test, link,
        ll, login, logout, ls, org, outdated, owner, pack, ping,
        pkg, prefix, profile, prune, publish, query, rebuild, repo,
        restart, root, run-script, search, set, shrinkwrap, star,
        stars, start, stop, team, test, token, uninstall, unpublish,
        unstar, update, version, view, whoami
    
    Specify configs in the ini-formatted file:
        /home/runner/.npmrc
    or on the command line via: npm <command> --key=value
    
    More configuration info: npm help config
    Configuration fields: npm help 7 config
    
    npm@9.3.1 /usr/local/lib/node_modules/npm
    
  • check npm version
    npm version
    9.3.1
    
  • In npm v9 npm bin is removed: https://github.blog/changelog/2022-10-24-npm-v9-0-0-released/#%E2%9A%A0%EF%B8%8F-notable-breaking-changes
  • As $PATH is set by npm bin in
    PATH=$(cd $GITHUB_ACTION_PATH; npm bin):$PATH
    it seems this solution won't work with npm v9

Conclusion

I've executed prettier with npm exec prettier and it worked, step succeeded. I'm not sure if that's the way. In that case npm install might be unneeded as according to the docs npm exec can fetch packages also. But I'm not too much into Node and npm so I leave this decision for you 😃

@semseysandor semseysandor added the bug Something isn't working label Feb 18, 2023
@david-allison
Copy link

Duplicate of #113

@semseysandor
Copy link
Author

A workaround to use this action in your job: pin npm to version 8

- name: Install npm v8
  run: npm i -g npm@8

- name: Check code-style
  uses: creyD/prettier_action@v4.2
  with:
    dry: true
    prettier_options: --check **/*.{md,yml}

@semseysandor
Copy link
Author

Duplicate of #113

Oh, yes it is. But here are the reasons also, not just a bug report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants