-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Prettier not found if it's a dev-dependency #12731
Comments
I think the main issue here is that the working directory for prettier is not being set to the project root that Zed has open. You can see this in the provided logs:
|
This issue is currently a blocker for me adopting Zed. Indeed, the problem appears to be that, given a formatting command to run, Zed is executing that command in its app config directory ( I think a bigger issue here is that Zed currently makes no attempt to detect whether a local version of Prettier exists in the project. The current assumption seems to be that using the local version is a niche desire, and for all I know it is, but this what I want to do in literally every project ever—not least because I was hoping to do this as a workaround for the frustrating issue of #8534. |
@mattlucock (or anybody else who experiences this issue), I would love to get a project example or at least to know about it more. #8837 should have fixed issues with the working directory (and there was a set of prettier-related fixes around that time) The main remaining culprit could be yarn support: it's nonexistent (issue: #10107 , PR to fix that: #13644) Another potential issue could be due to I've tried to replicate the original issue (as the only few code-related details in this issue) with
and the following extra {
"singleQuote": true,
"semi": false,
"trailingComma": "es5",
"printWidth": 80,
"plugins": ["prettier-plugin-css-order"]
} and that seems to work: the file gets formatted, LSP logs show that all plugins were picked correctly: So, if the project could not be shared, not based on yarn and does not work still, more log output (~/Library/Logs/Zed/Zed.log one and the LSP one from the screenshot) is needed. |
@SomeoneToIgnore Yes, I can provide a project. For me, it happens in https://github.com/exer7um/exer7um.com. I have If I add Prettier to the dependencies, then everything works fine. In your example, you install Prettier as a dependency, so it works correctly. |
Thank you so much! This case is relatively easy to fix as currently, Zed checks every package.json with zed/crates/prettier/src/prettier.rs Lines 95 to 98 in 89fbd65
(or walks up the stack searching for The main reason for doing so was to avoid cases when some "stale" prettier is in I hope to fix this before end of Monday, but feel free to do the same if you want to . @mattlucock , I'm very interested in your case still, you've got such a fiery intro with the words |
@ExEr7um can you test #14403 ? But on my test projects and https://github.com/exer7um/exer7um.com , it works now. |
Found a monorepo project example, seems to work for me too. |
Do not require the `prettier` dependency name to be in package.json's [dev]Dependencies, instead just checking the `node_modules` contents. Release Notes: - Improved `prettier` detection to pick up its installation from transitive dependencies ([12731](#12731)
Do not require the `prettier` dependency name to be in package.json's [dev]Dependencies, instead just checking the `node_modules` contents. Release Notes: - Improved `prettier` detection to pick up its installation from transitive dependencies ([12731](#12731)
Do not require the `prettier` dependency name to be in package.json's [dev]Dependencies, instead just checking the `node_modules` contents. Release Notes: - Improved `prettier` detection to pick up its installation from transitive dependencies ([12731](#12731)
@SomeoneToIgnore I did not at all intend saying that this issue was a blocker to be 'fiery'; it was actually supposed to be calm and objective. The bar to me adopting Zed is high since I already have something that works well for me. Therefore, incompatibilities with existing projects that appear to simply be bugs or similar issues with Zed are reasons why I can't adopt Zed. I also was definitely not intentionally ignoring you, which you seemed to infer from me taking longer than three days to reply to you. Upon reflection I think I misread this issue. The problem I was having was very related and appeared to manifest in a very similar way, but I don't think it was actually the same issue. I apologise for the confusion. I hadn't touched Zed since last week, but launching it today and performing an update to the latest version, the specific issue I was having appears to be magically resolved now; the exact same configuration that was failing a week ago in the manner I described is suddenly working now. I'm not sure what happened and I'm fine to not find out. If OP's issue has been resolved, you can close this issue. |
Thank you so much for the update. Please, ping me in any of the other issues you find especially irritating and I'll try to work around them. |
Thank you! Everything works as expected now. |
Check for existing issues
Describe the bug / provide steps to reproduce it
I have my personal Prettier config in an npm package, and prettier is a dev-dependency of that config. When I try to use Prettier in Zed, it falls back to default Prettier because
package.json
doesn't have Prettier dependency in it, it only has my config dependency.In my config I have some prettier plugins, which are not installed in default Prettier, so formatting fails.
In VSCode it works fine.
Environment
Zed: v0.138.4 (Zed)
OS: macOS 14.5.0
Memory: 32 GiB
Architecture: aarch64
If applicable, add mockups / screenshots to help explain present your vision of the feature
No response
If applicable, attach your
~/Library/Logs/Zed/Zed.log
file to this issue.The text was updated successfully, but these errors were encountered: