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 not installed correctly #113

Closed
kewbish opened this issue Feb 18, 2023 · 9 comments
Closed

[BUG] prettier not installed correctly #113

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

Comments

@kewbish
Copy link

kewbish commented Feb 18, 2023

What exactly happened?

Our team is using this prettier action to format code on push to main. The action was working as of ~8h ago, but as of ~5h ago fails to install the prettier command correctly. No changes to our GitHub workflow were made and we've tried rerunning the workflow several times with the same result. We get:

Installing prettier...
Checking plugin: prettier-plugin-go-template
Prettifying files...
Files:
/home/runner/work/_actions/creyD/prettier_action/v4.2/entrypoint.sh: line 74: prettier: command not found

on action run.

Steps to reproduce the behavior:

  1. Go to Actions tab on a GitHub repository
  2. Manually initiate an action using this action
  3. Scroll down to job run (an example here)
  4. See error

What should've happened?
The Action should have correctly installed prettier.

How did it look?
Full stack trace:

Run creyD/prettier_action@v4.2
  with:
    prettier_options: --write **/*.+(js|html|css|json|md|yaml|yml)
    prettier_plugins: prettier-plugin-go-template
    github_token: ***
    only_changed: true
    commit_message: Prettified Code!
    same_commit: false
    file_pattern: *
    dry: false
    prettier_version: false
    working_directory: false
Run PATH=$(cd $GITHUB_ACTION_PATH; npm bin):$PATH /home/runner/work/_actions/creyD/prettier_action/v4.[2](https://github.com/ubccsss/ubccsss.org/actions/runs/4206994917/jobs/7305175027#step:3:2)/entrypoint.sh
  PATH=$(cd $GITHUB_ACTION_PATH; npm bin):$PATH /home/runner/work/_actions/creyD/prettier_action/v[4](https://github.com/ubccsss/ubccsss.org/actions/runs/4206994917/jobs/7305175027#step:3:4).2/entrypoint.sh
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    INPUT_COMMIT_MESSAGE: Prettified Code!
    INPUT_COMMIT_DESCRIPTION: 
    INPUT_SAME_COMMIT: false
    INPUT_COMMIT_OPTIONS: 
    INPUT_FILE_PATTERN: *
    INPUT_PRETTIER_OPTIONS: --write **/*.+(js|html|css|json|md|yaml|yml)
    INPUT_DRY: false
    INPUT_PRETTIER_VERSION: false
    INPUT_ONLY_CHANGED: true
    INPUT_PRETTIER_PLUGINS: prettier-plugin-go-template
    INPUT_WORKING_DIRECTORY: false
    INPUT_GITHUB_TOKEN: ***
Installing prettier...
Checking plugin: prettier-plugin-go-template
Prettifying files...
Files:
/home/runner/work/_actions/creyD/prettier_action/v4.2/entrypoint.sh: line [7](https://github.com/ubccsss/ubccsss.org/actions/runs/4206994917/jobs/7305175027#step:3:7)4: prettier: command not found
Problem running prettier with --write **/*.+(js|html|css|json|md|yaml|yml)
Error: Process completed with exit code 1.

Where did you encounter the problem?

@kewbish kewbish added the bug Something isn't working label Feb 18, 2023
@shawnyu5
Copy link

Same here, workflows using this actions randomly started failing recently with the same error /home/runner/work/_actions/creyD/prettier_action/v4.2/entrypoint.sh: line 74: prettier: command not found

@infotexture
Copy link
Contributor

@WilliamsCJ
Copy link

Version 3.3 appears to be the latest version that is not affected.

@Piet2001
Copy link

Here the same issue in multile repo's.

@semseysandor
Copy link

A workaround for this bug: pin npm to version 8 in your job (if it's possible)

- 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

I've done 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 confirms 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
  • $PATH is set by npm bin in
    PATH=$(cd $GITHUB_ACTION_PATH; npm bin):$PATH

Conclusion

It seems currently this action won't work with npm v9.
So 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 though 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 😃

zapteryx added a commit to ZPTXDev/Quaver that referenced this issue Feb 19, 2023
There's currently an issue (creyD/prettier_action#113) preventing the action from running properly on npm v9.
@creyD
Copy link
Owner

creyD commented Feb 19, 2023

Hi all! Thanks for the quick and efficient coordination. As I can see you already worked out a workaround. I can also add it to the readme to support struggling users. Would it be a good idea to pin the npm version in the action? Or what ways forward should we think of?

@creyD
Copy link
Owner

creyD commented Feb 19, 2023

Alright, there is now v4.3 which has the bugfix and a note for the workaround in the readme. Thanks for everyone who hel'ped and supported here! All repos using the action with the @master or just plain prettier_action without a version specified don't need to change anything. Everyone else who pinned an earlier version should either change their workflow to the new version or add the workaround.

@creyD creyD closed this as completed Feb 19, 2023
kewbish added a commit to ubccsss/ubccsss.org that referenced this issue Feb 19, 2023
See creyD/prettier_action#113, force-pushing to immediately unblock.
@Viicos
Copy link

Viicos commented Feb 19, 2023

Would it be a good idea to pin the npm version in the action? Or what ways forward should we think of?

I think it's a good practice to pin versions when possible, so that the behavior will always be the same. Then when something gets an update, it can be manually updated on the action, making sure that everything's working as excepted

infotexture added a commit to dita-ot/docs that referenced this issue Feb 19, 2023
https://github.com/creyD/prettier_action/releases/tag/v4.3

Workaround for issues with NPM v9:
- creyD/prettier_action#113 (comment)

Signed-off-by: Roger Sheen <roger@infotexture.net>
vEnhance added a commit to vEnhance/evans_django_tools that referenced this issue Feb 19, 2023
rjhuijsman added a commit to 3rdparty/dev-tools that referenced this issue Feb 20, 2023
We were bitten by creyD/prettier_action#113,
which breaks our code style check and therefore our ability to submit
PRs.

The fix is to update that action to v4.3. And to yell and gesticulate
wildly about how GitHub Actions shouldn't change the major version of
the `npm` runtime without us taking action!
aviator-app bot pushed a commit to 3rdparty/dev-tools that referenced this issue Feb 20, 2023
We were bitten by creyD/prettier_action#113,
which breaks our code style check and therefore our ability to submit
PRs.

The fix is to update that action to v4.3. And to yell and gesticulate
wildly about how GitHub Actions shouldn't change the major version of
the `npm` runtime without us taking action!
infotexture added a commit to infotexture/dita-bootstrap that referenced this issue Feb 26, 2023
https://github.com/creyD/prettier_action/releases/tag/v4.3

Workaround for issues with NPM v9:
- creyD/prettier_action#113 (comment)

Signed-off-by: Roger Sheen <roger@infotexture.net>
alexanderl19 added a commit to icssc/zotmeet-legacy that referenced this issue Mar 2, 2023
alexanderl19 added a commit to icssc/zotmeet-legacy that referenced this issue Mar 2, 2023
* ci: errors on non-existent files

* this should get formatted

* without prettier_options

* fix: creyD/prettier_action#113

* this should get formatted?

* Prettified Code!

---------

Co-authored-by: alexanderl19 <alexanderl19@users.noreply.github.com>
diogotcorreia added a commit to leic-pt/resumos-leic that referenced this issue Mar 4, 2023
There was a bug in 4.2 (due to a NPM update) that prevented it
from working: creyD/prettier_action#113
diogotcorreia added a commit to leic-pt/resumos-leic that referenced this issue Mar 4, 2023
There was a bug in 4.2 (due to a NPM update) that prevented it from working: creyD/prettier_action#113
michael-siek added a commit to dequelabs/watcher-examples that referenced this issue May 12, 2023
Steven-Hsu1 added a commit to Powellelism/Coffee-Recipe-Management-System that referenced this issue May 4, 2024
Steven-Hsu1 added a commit to Powellelism/Coffee-Recipe-Management-System that referenced this issue May 4, 2024
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

8 participants