Michael Sims
Michael Sims

Reputation: 2523

How to fix unable to find module where it can be found under an incorrect name

I ran into an unusual problem using IntelliJ with a project, where when I clone the project from my GitHub repository, it would not run though it would build just fine. Then I discovered that when I ran the command mvn clean compile it would then run just fine. After opening an incident with JetBrains, the support person cloned the project to his machine and was getting errors of not being able to find a specific module that is in the module-info file.

So I then created a clean environment in a virtual machine and was getting the same error that he got. But IntelliJ fixed that error by creating a new entry in the module-info file where it referenced that library using a shorter name.

Specifically, in my normal working environment (on my Mac), the module is included using this line:

requires org.kohsuke.github.api;

but the fix in the virtual machine was to delete that line and use this one instead:

requires github.api;

But when I make that same change on my Mac, IntelliJ says that it cannot find module github.api.

I'm at a loss as to how to fix this. I'm thinking that I need to possibly delete something and let IntelliJ / Maven re-build any references to that module so it can "start from scratch" - essentially - but I don't know exactly how to do that or even if my thinking is in the right direction.

So I'm seeking any wisdom or advice from here and will appreciate any advice that you can render.

Thank you,

Mike Sims

Upvotes: 1

Views: 1145

Answers (1)

Michael Sims
Michael Sims

Reputation: 2523

The support person from JetBrains and I worked on this problem for the better part of the day. Ultimately, we were able to solve the problem by deleting the ~/Library/caches/JetBrains folder and also the .idea folder from the project folder itself while the project was closed. Then I clicked on Open, went to that project folder, clicked on the POM file and opened it and imported the project using the Maven POM file.

Concerning the library that was not being recognized by the correct name from my project, I realized that some time ago, I was involved with a pull request for the library to have an Auto-Name property added to its manifest file, and I remember specifically modifying the libraries .jar file to test this change. That change has not yet been published. However, during the process of troubleshooting, I ended up completely deleting my local Maven .m2 folder (along with my ~/Library/Application Support/JetBrains folder) which prompted the re-download of that library but in spite of that, IntelliJ was still referencing the name that I had manually added into that jar file some time ago.

The issue wouldn't resolve until I deleted that cache folder and the .idea folder.

We were never able to get to the heart of why IntelliJ was hanging on to that phantom name for the library, but that answer to that is in that cache folder somewhere.

I realize that this scenario is highly unusual and won't occur for most developers, but I'm posting the solution just in case someone else runs across a similar situation.

Upvotes: 1

Related Questions