Duplicate library dependency after version change

I'm having a problem with the sbt dependencies.
When I change the version of a dependency intellij will retrieve it and will add it to the project as a library.
The problem is that it wont remove the previous version, leaving both the versions there.
This is causing bad class resolution (I think).
To fix this I would need to regenerate the whole project struture.

I'm using latest stable version of intellij and scala plugin.

Any idea if its only me?

11 comments
Comment actions Permalink

Yes, me too. This has been driving me crazy since I first started using it (many months ago).

Even if I go to the library screen and remove them, when I re-import the sbt build file, they appear again, even though there is no reference to them anywhere.

And no, they aren't transitive dependencies of another library

0
Comment actions Permalink

The local temporary fix is to remove the lib and add the new version to the modules manually
in the project settings

0
Comment actions Permalink

Hi! No, unfortunately it's not only you. We are aware of this bug, please follow this ticket on Youtrack to get updates about it.

0
Comment actions Permalink

Thank you, but that's not the same bug I'm seeing. The libraries don't turn gray, they are still black and still being used. In my case, I have a multi-module project. At the end of the sbt refresh, some modules are using the new version of the library and some modules are still using the old. I can't remove the old libraries because they're still being used.

0
Comment actions Permalink

Ok, your problem might have different cause. Could you please do the following: recursively remove all `target` directories and their contents from your project's directory and refresh project in IDEA. Will some modules still use outdated libraries after you've done this?

0
Comment actions Permalink

Yes, thank you. That works right after I remove the directories. If I then change a version and update again, I get duplicates.

If I remove them every time, that might be a solution for now.

0
Comment actions Permalink

Yes this is super frustrating, I have to delete my .idea directory and re-import to get everything working again with only the newer versions.  

0
Comment actions Permalink

If we delete all the idea dirs and import the project again it works.
But for big projects is is a big pain.

This only started happening in the most recent versions of the plugin.
Cannot precise which.

0
Comment actions Permalink

I know this is a old post and thought it may help others.

We recently upgraded our elastic search version and ended up with the same issue of older versions of Jar getting added in the web application.

I did deleted the .idea folder and it fixed the issue as others said.

One of my other team mate, fixed this by deleting the older jar file from the lib folder found under the src/webapps/web_inf.

0
Comment actions Permalink

Hi,

Any news on that, it happens quite easily with multimodule maven projects even on this version:

IntelliJ IDEA 2020.1.1 (Community Edition)
Build #IC-201.7223.91, built on April 30, 2020
Runtime version: 11.0.6+8-b765.40 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 5.4.0-33-generic

0
Comment actions Permalink

Issue still occurs on 2020.1.3 Ultimate - after reloading dependency is added with new version, but the old one is not deleted. I need to restart IntelliJ to import dependencies properly.

0

Please sign in to leave a comment.