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

Executable prettier not found #1516

Closed
rkm opened this issue Jun 17, 2020 · 3 comments · Fixed by #1521
Closed

Executable prettier not found #1516

rkm opened this issue Jun 17, 2020 · 3 comments · Fixed by #1521

Comments

@rkm
Copy link
Contributor

rkm commented Jun 17, 2020

hello hello!

As discussed on discord, I'm having an issue running prettier via pre-commit:

$ pre-commit --version
pre-commit 2.5.1

$ cat .pre-commit-config.yaml
repos:
  - repo: https://github.com/prettier/prettier
    rev: 2.0.5
    hooks:
      - id: prettier

$ pre-commit clean
Cleaned /home/rkm/.cache/pre-commit.

> pre-commit run prettier --files README.md
[INFO] Initializing environment for https://github.com/prettier/prettier.
[INFO] Installing environment for https://github.com/prettier/prettier.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
prettier.................................................................Failed
- hook id: prettier
- exit code: 1

Executable `prettier` not found

it seems like prettier is installed correctly, but the symlink to it is not created:

$ find ~/.cache/pre-commit/ -name prettier.js
/home/rkm/.cache/pre-commit/repoes79dg4v/bin/prettier.js

$ ls -l $(find ~/.cache/pre-commit/ -name node_env-default)/bin
total 70376
-rwxr-xr-x. 1 rkm rkm     3702 Jun 17 17:30 activate
-rwxr-xr-x. 1 rkm rkm     3964 Jun 17 17:30 activate.fish
-rwxr-xr-x. 1 rkm rkm 72052312 Jun  2 14:33 node
lrwxrwxrwx. 1 rkm rkm        4 Jun 17 17:30 nodejs -> node
lrwxrwxrwx. 1 rkm rkm       38 Jun 17 17:30 npm -> ../lib/node_modules/npm/bin/npm-cli.js
lrwxrwxrwx. 1 rkm rkm       38 Jun 17 17:30 npx -> ../lib/node_modules/npm/bin/npx-cli.js
-rwxr-xr-x. 1 rkm rkm      355 Jun 17 17:30 shim 

(doing the same in a docker container results in a prettier symlink being created there).

I suspect my VM may be borked somehow, but not sure how to debug this further. Any thoughts? Thanks!

@asottile
Copy link
Member

thrugh some digging on discord we found the following:

> env | grep -i npm
NPM_CONFIG_USERCONFIG=/home/rkm/.config/npm/npmrc

and

> cat ~/.config/npm/npmrc
prefix=${XDG_DATA_HOME}/npm
cache=${XDG_CACHE_HOME}/npm
tmp=${XDG_RUNTIME_DIR}/npm
init-module=${XDG_CONFIG_HOME}/npm/config/npm-init.js

which is probably the issue

@rkm
Copy link
Contributor Author

rkm commented Jun 19, 2020

ok, so I did not have XDG_CACHE_HOME set and npm seemed to be getting confused (instead of defaulting this to ~/.cache like most other tools do). prettier now works after re-installing!

I'm not sure if we want to do any more debugging on how exactly this broke, but I'm happy to close. thanks again!

@rkm rkm closed this as completed Jun 19, 2020
@asottile
Copy link
Member

I think I can actually make pre-commit avoid this problem case independent of a misconfigured system, I'd like to try and do that first

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

Successfully merging a pull request may close this issue.

2 participants