“What is wrong with my IntelliJ IDEA ?”

Stéphane Derosiaux
Powerspace Engineering
3 min readMar 16, 2016

--

ffs IDEA, Y U NO compile?!

Every IDEA developer knows what it is.

IntelliJ IDEA is a really great IDE to work with. All those features, all those shortcuts. The refactoring options are truly useful. The interface is quite nice, the IDE is not slow (except the indexing process that can be very frustrating, but hopefully, that happens rarely), and it has a lot of good plugins.

But sometimes, it just fails. It fails to resolve some dependencies it could before. It has troubles with the Scala macros and the compilation generated classes. It’s not working for some reason. Messages are not clear. Sometimes, you just changed your git branch and IDEA is totally off. Another time, you import a new package and you’re stuck, nothing works.

You know it’s not right : it should work, it should compile, what the hell ? Or the well know : “It’s working on my colleague’s computer !” “It’s working on the command line !”

That’s often a sign that your code is not faulty, but IDEA is.

Several tricks to try when that happens.

Maven re-import

Sometimes, you need to force IDEA to reimport the dependencies of the projects. That often the first thing to try. Either a specific project, or the whole solution.

Invalidate cache/restart

Well known among IDEA community. Slow and painful, because IDEA will reindex everything on startup and you’re good to take a new coffee. But at least, it often works.

Start fresh

Still not working ? Try the hard way.

Remove the folder “.idea” on the root, the different folders “target”, and the misc “*.iml” dispatched in the modules. And reimport the project fresh into IDEA.

The maven version used by IDEA

When you are using some Scala features, it’s possible you need to upgrade your maven version. IDEA is using by default a bundle one.

Cmd+Maj+A : maven

Maven home directory : maybe you should not used the bundle version “Bundled (Maven 3)”. In our case, we were using some advanced macros Scala features, and we needed to use a more recent Maven.

If you have some more tips, feel free to share!

If you’re not me, come say hi on twitter : https://twitter.com/chtefid

--

--