Why this error? Runs just fine
已回答
Why am I getting this error on newly created projects' sample code? It runs just fine with shift+F10

IntelliJ IDEA 2023.3.4 (Community Edition)
File > New > Project > Build system IntelliJ > JDK 21 from dropdown
请先登录再写评论。
Hello Marius,
Please try to remove SDKs from “Project Structure | SDKs” and then add JDK 21. Will it help?
Creating a new project this error happens every time. Toggling “No SDK” / “21”, as you suggest, seems to fix it.
Pretty janky behaviour…
Marius,
Is it possible to provide logs (https://intellij-support.jetbrains.com/hc/en-us/articles/207241085-Locating-IDE-log-files) after reproducing the issue? You may share files via https://uploads.jetbrains.com/ form.
Have you tried to completely delete all SDKs from the list, restart IDE and add single JDK. Does it help?
I emptied the recent projects and deleted the logs and then created a new project to get fresh logs. Here they are:
Upload id: 2024_03_07_UXXtgWmwW5TBPBxnrwfoAe (file: idea.log)
If I delete all (one, 21) SDKs from "Project Structure >SDKs" then it automatically fixes itself when I click OK. It's good that it fixes itself, but I shouldn't have to do this every time I create a new project, no?
Marius,
Sure, it shouldn't work this way. Could you please try to run “File | Invalidate Caches” selecting “Clear file system cache” and “Mark downloaded shared indexes as broken” option? Will it help?
That did the trick! I can now create new projects without the original error.
Any theories on what could have happened?
And thanks for the help!
Marius,
It's hard to say for sure, but there might be index corruptions when IDE isn't closed properly. E.g. on system crash or power outage.
I see. Again, thanks for the help!
Marius,
You are welcome!