使用IntelliJ构建项目时遭遇sbt.compiler.EvalException类型错误求助
Hey there! Sorry to hear you're hitting this sbt error so early on with IntelliJ—let's work through this together. Since it's happening even with a brand new project, we can totally rule out your code being the issue, which is a relief. Here are some steps to try that usually fix this kind of sbt/IntelliJ mismatch:
Invalidate IntelliJ's caches and restart
This is the classic first fix for weird IDE build glitches. Go toFile > Invalidate Caches..., check all the boxes in the pop-up, and click "Invalidate and Restart". Corrupted cached data is super common when you're setting up a new IDE, and this clears it out completely.Verify IntelliJ's sbt settings
Head toFile > Settings > Build, Execution, Deployment > Build Tools > sbt(on Mac it'sIntelliJ IDEA > Settings...). Make sure:- The sbt launcher is set correctly—either "Use sbt from project configuration" (if your fresh project specifies a version) or the latest launcher version you installed.
- The Java SDK selected here matches what sbt needs. Most recent sbt versions require Java 11 or higher, so if you're on an older Java version, that could cause type errors during evaluation.
Update IntelliJ to the latest version
Older IDE versions sometimes have compatibility bugs with newer sbt releases. Go toHelp > Check for Updates(Mac:IntelliJ IDEA > Check for Updates) and install any available updates. This often fixes underlying integration issues between IntelliJ and sbt.Test sbt directly in the terminal
Open your project's root folder in a terminal, runsbt clean compile, and see if you get the same error. If the terminal build works fine, the problem is with IntelliJ's integration, not sbt itself. In that case, try reimporting your project: go toFile > New > Project from Existing Sources..., select your project folder, choose "Import project from external model > sbt", and walk through the import wizard again.Disable any new Scala/sbt plugins
If you've installed any IntelliJ plugins for Scala or sbt since starting out, try disabling them temporarily. Go toFile > Settings > Plugins, turn off any non-default Scala-related plugins, restart the IDE, and test the build again. Sometimes plugins can interfere with the build process unexpectedly.
If none of these work, could you share the full error stack trace from IntelliJ's build output? That would help pinpoint exactly which expression is causing the type error, even in a fresh project.
内容的提问来源于stack exchange,提问作者Eimana

