IntelliJ中刷新SBT项目失败及idea-shell命令无效问题求助
Hey there, let's tackle that frustrating SBT refresh issue you're facing—glad to hear you're not the only one hitting this! That "invalid command: idea-shell" error pops up because idea-shell was a legacy command used by older versions of the IntelliJ Scala plugin, and it's no longer supported by newer SBT versions or updated plugins.
Here are the step-by-step fixes to get your project refreshing smoothly again:
Update your IntelliJ Scala Plugin
Open IntelliJ's Settings (Preferences if you're on a Mac), head to the Plugins section, search for the Scala plugin. If there's an update available, install it and restart IntelliJ. Newer plugin versions use updated SBT commands that don't rely on the deprecatedidea-shell.Upgrade your project's SBT version
Check your project'sbuild.sbtorproject/build.propertiesfile. If you're using an older SBT version (pre-1.x maybe?), upgrade it to a stable recent release (like the latest 1.x version). Newer SBT builds have dropped support foridea-shell, so aligning your version with the plugin will fix the command mismatch.Wipe caches and restart
Sometimes stale cache files cause weird misalignments:- Close IntelliJ completely.
- Delete the
.sbtand.ideafolders in your project directory (make sure to back up any custom configs you've added first!). - Reopen IntelliJ, go to
File > Invalidate Caches..., check all the available options, then click "Invalidate and Restart".
Re-import your project from scratch
After restarting, don't just hit the refresh button. Instead, go toFile > New > Project from Existing Sources..., select your project's root directory, and follow the prompts to re-import it as an SBT project. This forces IntelliJ to generate fresh, compatible configuration files.
A quick sanity check: Try running sbt shell directly in your terminal. If that works without errors, the issue is definitely with IntelliJ's plugin/cache setup, not your project's SBT configuration.
内容的提问来源于stack exchange,提问作者pme

