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?

7

I've started to encounter this (as well as several colleagues) in 2020.2: 

IntelliJ IDEA 2020.2.2 (Ultimate Edition)
Build #IU-202.7319.50, built on September 14, 2020
Runtime version: 11.0.8+10-b944.31 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 10.15.6

3

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.

2

Same here, very annoying. Still persist in 2020.3.
My tests are going completely mad.

2

Same issue:

IntelliJ IDEA 2020.1.2 (Community Edition)
Build #IC-201.7846.76, built on June 1, 2020
Runtime version: 11.0.7+10-b765.53 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 10.15.5
GC: ParNew, ConcurrentMarkSweep
Memory: 1979M
Cores: 16
Non-Bundled Plugins: CheckStyle-IDEA, Lombook Plugin, com.dubreuia, org.jetbrains.kotlin

2

Hello everyone, I may have found a solution to this problem. Its not the best, but it helps a lot. In case you are having the same issue, use the following steps:

1. close idea
2. go to project folder and clean it with these three commands:

rm -rf **/*.iml
rm -rf .idea/misc.xml
rm -rf .idea/libraries/

3. open idea and import the project again (for me this means only "add pom as maven project", not sure about other types)

Next time you open idea, you need to import the project, but none of the other settings will be broken, which is kind of helpful. All run configurations are present, IDE settings set (except for JAVA version) and database connections also still there. It is very important to delete also misc.xml file as it seems to do the trick.

2

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

1
Avatar
Permanently deleted user

This is happening to me in 2020 and I'm surprised this bug has not been fixed in 5 years.

 

IntelliJ IDEA 2020.2 (Ultimate Edition)
Build #IU-202.6397.94, built on July 27, 2020
Runtime version: 11.0.7+10-b944.20 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 10.14.6

1

This is happening to me and to my colleagues as well with Java on 2020.2.1

IntelliJ IDEA 2020.2.1 (Ultimate Edition)
Build #IU-202.6948.69, built on August 25, 2020

This is making us crazy!

1

Update to 2020.2.2 did not fix the problem :-(

IntelliJ IDEA 2020.2.2 (Ultimate Edition)
Build #IU-202.7319.50, built on September 15, 2020
Runtime version: 11.0.8+10-b944.31 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0

1

Hello, any update to this issue? Still happening in 2020.3.1

IntelliJ IDEA 2020.3.1 (Ultimate Edition)
Build #IU-203.6682.168, built on December 29, 2020

Runtime version: 11.0.9.1+11-b1145.63 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 10.16
GC: ParNew, ConcurrentMarkSweep
Memory: 4916M
Cores: 12

1

Adding mine to the list on the latest build.

IntelliJ IDEA 2020.3.2 (Ultimate Edition)
Build #IU-203.7148.57, built on January 25, 2021

Runtime version: 11.0.9.1+11-b1145.77 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 10.15.7
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 16

1

Same company as Derek.  This is pervasive through our organization (which contracts with intellij) and is causing problems with everything from UTs to basic compilation.

IntelliJ IDEA 2020.3.2 (Ultimate Edition)
Build #IU-203.7148.57, built on January 25, 2021

Runtime version: 11.0.9.1+11-b1145.77 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 10.15.7
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 16

1

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
Avatar
Permanently deleted user

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

0
Avatar
Permanently deleted user

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

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
Avatar
Permanently deleted user

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

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
Avatar
Permanently deleted user

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
Avatar
Permanently deleted user

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
Avatar
Permanently deleted user

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

I have the same problem:

 

IntelliJ IDEA 2020.2.2 (Ultimate Edition)
Build #IU-202.7319.50, built on September 15, 2020
Licensed to ...
Subscription is active until ...
Runtime version: 11.0.8+10-b944.31 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 15933M
Cores: 8
Registry: ide.tooltip.initialDelay=641, go.run.processes.with.pty=false
Non-Bundled Plugins: BashSupport, Key Promoter X, Lombook Plugin, String Manipulation, com.jetbrains.ChooseRuntime, de.espend.idea.localization, de.netnexus.camelcaseplugin, com.ppolivka.gitlabprojects, mobi.hsz.idea.gitignore, MavenRunHelper, com.bsb.intellij.plugins.xmlbeans, com.intellij.lang.jsgraphql, org.jetbrains.plugins.go

 

/edit

For it works to remove the wrong dependencies from my local maven repository. 

0

I've the same problem.

IC-202.7660.26, JRE 11.0.8+10-b944.34x64 JetBrains s.r.o., OS Linux(amd64) v5.4.0-48-generic, screens 1920x1080, 1920x1080, 1920x1080

To fix I need to:

  • close intellij
  • git clean -dfx 
  • reimport the project on intellij.

If I delete the librairies in double in structure -> librairies, when I change the pom.xml, they comme back in twice.

 

Best regards,

Stephane.

 

0

Same here. I managed to have the proper dep resolved on the 3rd attempt at removing manually the older deps from the project structure (right click on any External library -> Open Library Settings (F4)). Dunno why the previous attempts failed.

And still I'm sure that older maven deps will come back somehow as soon as I do any change to my project poms.

0

Same problem here. Others in my company are reporting the same.

IntelliJ IDEA 2020.2.4 (Ultimate Edition)
Build #IU-202.8194.7, built on November 24, 2020


Runtime version: 11.0.9+11-b944.49 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 10.15.7
GC: ParNew, ConcurrentMarkSweep
Memory: 1981M
Cores: 8

0

I can report the same problem, and it's been going on for multiple IntelliJ versions now.

Thanks Matej Kobza, I can use your solution as a workaround to remove duplicate libraries. Until now, I removed the whole .idea directory which removed way more than the libraries. Nevertheless, I still have to repeat it every time I change a dependency version or switch to a branch that is using different versions.

Here's my build information:

IntelliJ IDEA 2020.3.2 (Ultimate Edition)
Build #IU-203.7148.57, built on January 26, 2021
Runtime version: 11.0.9.1+11-b1145.77 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 2916M
Cores: 12
Non-Bundled Plugins: com.intellij.ideolog, net.seesharpsoft.intellij.plugins.csv, com.ppolivka.plugin.gitcleaner, mobi.hsz.idea.gitignore, org.zalando.intellij.swagger, Builder Generator, com.siberika.idea.pascal, MavenRunHelper, com.intellij.plugin.adernov.powershell, org.jetbrains.kotlin, com.intellij.gwt, PlantUML integration, org.asciidoctor.intellij.asciidoc

 

Update:
I just saw another thread where a solution has been proposed that is working for me.

0

Hello, Martin Leim could you tell us what solution has finally helped you? You provided a link to a thread but the link is not working.

Currently I am using Matej Kobza's solution. It removes older library versions but when some library is updated, then its older version is not removed, and needs to be removed manually. I tried But2 Ene's solution as well but it removes too much configuration.

0

Hi Arjana Bivainiene,

sorry, I had somehow messed up the link. It is fixed now.

0

Thank you for the reference, Martin Leim

In my case, there was a reference to a parent in the Maven pom.xml that was external to the project and had to be fetched from the repository. But an empty <relativePath></relativePath> was missing in the parent module reference, and a warning could be seen when building the project using Maven. Having fixed the parent information, duplicate libraries disappeared from the project library list.

0

This issue has been going on for a long long time and I find it unacceptable that they haven't give this bug some type of priority.

All of the manual solutions suggested here are time consuming. Imagine having to do this over time. 

I would have stopped using Intellij if it wasn't for the company I work for pays for it. I'm not a big fan of Eclipse, but the last few times I have used it appears that it has come a long way.

0

请先登录再写评论。