-
Notifications
You must be signed in to change notification settings - Fork 81
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
Apheleia does not format buffer with prettier
when installed locally (npx prettier ...
)
#217
Comments
It sounds like you might be using prettier in your project without adding it as a dependency to your package.json? in if Apheleia's internal virtual command |
Thanks for taking your time and for explaining. I checked the project, and we are setting Now, we have several sub-projects, and all of them specify prettier as a dependency, but could it be that the paths are not correctly resolved due to the relative link? That's just a wild guess. I could try to further debug the issue, if you prefer. |
Symlinks in node_modules/.bin are normal I think? So probably not that... What version of apheleia are you using? Looks like typescript-ts-mode was added in 3.2 If it's not that, give me a little more detail about your setup and I'll see what I can do? |
Apheleia should definitely use your Prettier binary installed at Lines 755 to 771 in 791346c
It's pretty straightforward - check if |
Hm, I just checked again, and all is working well, even when I do not install prettier globally. I am not sure if something has changed in the meantime, or if this problem has always been on my side.. Thanks a lot for explaining the details. They will help if I encounter this problem again! |
Sorry, I spoke too soon. The issue came back, and I found the reason: The line Is this a misconfiguration of the project? (I do not really think so). Or is this a limitation of Thanks! |
Are you using npm workspaces in your monorepo? iirc the issue with using |
Yes, we are using |
Hmm, in my limited experience repos using npm workspaces have a single node_modules dir at the root of the repo, rather than multiple node_modules dirs, one for each workspace's package.json. Sounds like you've got things set up differently? |
fwiw with a quick test I found |
I just had a look, and when using workspaces, |
Ok, so we can definitely adjust the behavior of Apheleia to handle the case of multiple We should be able to tackle that as part of #200 or I can do it as a follow-up. |
I also seem to be running into this issue, mono-repo, prettier works from npx, not from emacs, no errors given. Could it also be relevant to: #297 |
Okay, so now that #200 is long since merged, we can address this issue by fixing the behavior with nested Either way, I will research and fix the problem, eventually. But the process can be sped up if more context is available so I can test solutions. |
Somehow, Apheleia does not run
prettier
intypescript-ts-mode
, ifprettier
is installed locally vianpm
only.In the function
apheleia--run-formatter-process
,apheleia--format-command
is run to format the command.apheleia--format-command
removes thenpx
prefix (npx
->nil
), and so,(executable-find (car command)
searches forprettier
instead ofnpx prettier
. Ifprettier
is not in path, the buffer is not formatted.Is this behavior desired? It means that I have to install a global version of
prettier
that may not be identical to the one used in the project at hand.Thanks for looking into this!
The text was updated successfully, but these errors were encountered: