How to open an .iml project whose name is different than the folder?

Answered

We have an .iml/.idea-style project (not Maven or Gradle) that lives at the root of its Git repository. The Git repo is called (let's say) "OurProject", and contains an OurProject.iml file. On my machine, I check out our repository to C:\Dev\OurProject, and then tell IntelliJ to open the C:\Dev\OurProject folder, and it reads the project settings from C:\Dev\OurProject\OurProject.iml. All is well.

However, a colleague checked out the repository to C:\Dev\OurProject_master. So on their computer, when they do File > Open and select the "OurProject_master" directory, IntelliJ doesn't find the OurProject.iml file; instead it creates a new OurProject_master.iml file. We obviously don't want two versions of the same file cluttering Git and diverging from each other - and anyone else could check out the folder to any arbitrary folder, and we'd end up with a new .iml file each time.

We've tried doing File > Open and browsing to the actual .iml file, but that just opens it as a text file, not as a project.

Obviously my colleague could just rename their folder, but that's a hack. Is there a better option? (This feels like it should be easy.) How can we get IntelliJ to open an .iml file with a different name than the folder it's in (e.g. OurProject_master\OurProject.iml)?

7 comments
Comment actions Permalink

Hello Joe,

I just tried to reproduce the issue on my machine and it worked fine with renamed project folder. What IDE version doe you use? Is it possible to provide .iml file? Is it possible to reproduce the issue with any sample project?

 

0
Comment actions Permalink

Weird. Yesterday I tried renaming the .iml and then opening the directory in IntelliJ, and (when I figured out how to make a change that would hit the .iml file) it saved a new .iml file that matched the directory name.

But today, when I create a brand-new project, close it, rename the directory, and then open the directory in IntelliJ, it doesn't try to rename the .iml file. It keeps saving changes under the original filename.

I guess my test yesterday was backwards from my test today (renaming the file vs. renaming the folder), but I'm not sure how that would make a difference.

And I know I've seen several of my colleagues end up with their own .iml files, separate from the one that's checked into Git. It's only when they check out to a different folder name, and their .iml filenames match the folder name.

0
Comment actions Permalink

Below is the log from when I tried renaming the project file and opening the directory. (I didn't take it as far as doing anything that would re-create the original .iml file.) But as I mentioned above, that's actually backwards from what my colleagues are seeing - they're ending up with an extra .iml file with a different name, not re-creating the original name.

I don't know how my colleagues are getting into this state - I've only caught it after the fact. I'll try to alert them to let me know if it happens again.

My logs after renaming the project file:

2019-02-18 09:03:30,154 [ 312937] INFO - pl.projectlevelman.NewMappings - VCS Root: [] - [<Project>]
2019-02-18 09:03:30,154 [ 312937] INFO - pl.projectlevelman.NewMappings - VCS Root: [Git] - [<Project>]
2019-02-18 09:03:30,538 [ 313321] INFO - ellij.project.impl.ProjectImpl - 186 project components initialized in 495 ms
2019-02-18 09:03:30,551 [ 313334] INFO - le.impl.ModuleManagerComponent - 0 module(s) loaded in 12 ms
2019-02-18 09:03:30,837 [ 313620] INFO - PerformancePlugin - Performance Plugin is in silent mode
2019-02-18 09:03:31,362 [ 314145] INFO - tartup.impl.StartupManagerImpl - OpenFilesActivity run in 304ms under project opening modal progress
2019-02-18 09:03:31,386 [ 314169] INFO - ge.ExternalProjectsDataStorage - Loaded external projects data in 15 millis
2019-02-18 09:03:31,506 [ 314289] INFO - .diagnostic.PerformanceWatcher - Post-startup activities under progress took 462ms; general responsiveness: ok; EDT responsiveness: ok
2019-02-18 09:03:31,563 [ 314346] INFO - tartup.impl.StartupManagerImpl - C:/Dev/DAF/.idea case-sensitivity: expected=false actual=false
2019-02-18 09:03:31,683 [ 314466] INFO - tor.impl.FileEditorManagerImpl - Project opening took 1664 ms
2019-02-18 09:03:31,782 [ 314565] INFO - Json.PackageJsonUpdateNotifier - processPackageJsonFiles []
2019-02-18 09:03:31,841 [ 314624] INFO - pl.projectlevelman.NewMappings - VCS Root: [Git] - [<Project>]
2019-02-18 09:03:32,017 [ 314800] INFO - .diagnostic.PerformanceWatcher - Pushing properties took 0ms; general responsiveness: ok; EDT responsiveness: ok
2019-02-18 09:03:32,166 [ 314949] INFO - .diagnostic.PerformanceWatcher - Indexable file iteration took 140ms; general responsiveness: ok; EDT responsiveness: ok
2019-02-18 09:03:32,288 [ 315071] INFO - j.ide.ui.OptionsTopHitProvider - 106 ms spent to cache options in project
2019-02-18 09:03:32,289 [ 315072] INFO - tartup.impl.StartupManagerImpl - Some post-startup activities freeze UI for noticeable time. Please consider making them DumbAware to do them in background under modal progress, or just making them faster to speed up project opening.
2019-02-18 09:03:32,289 [ 315072] INFO - tartup.impl.StartupManagerImpl - Activity run in 107ms on UI thread
2019-02-18 09:03:32,545 [ 315328] INFO - cloudConfig.CloudConfigManager - === StatusBar.start create ===
2019-02-18 09:03:32,559 [ 315342] INFO - tartup.impl.StartupManagerImpl - MyStartupActivity run in 252ms on UI thread
2019-02-18 09:03:32,802 [ 315585] INFO - j.ide.ui.OptionsTopHitProvider - 176 ms spent on EDT to cache options in project
2019-02-18 09:03:35,556 [ 318339] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stdout]: Build process started. Classpath: C:/Users/t445857/AppData/Local/JetBrains/Toolbox/apps/IDEA-U/ch-0/183.5429.30/lib/jps-launcher.jar;C:/Program Files/Java/jdk1.8.0_202/lib/tools.jar;C:/Users/t445857/AppData/Local/JetBrains/Toolbox/apps/IDEA-U/ch-0/183.5429.30/lib/optimizedFileManager.jar
2019-02-18 09:03:35,602 [ 318385] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
2019-02-18 09:03:35,602 [ 318385] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: Defaulting to no-operation (NOP) logger implementation
2019-02-18 09:03:35,602 [ 318385] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2019-02-18 09:03:37,658 [ 320441] INFO - s.CompilerReferenceServiceBase - backward reference index reader is opened
2019-02-18 09:03:37,852 [ 320635] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stdout]: Build process started. Classpath: C:/Users/t445857/AppData/Local/JetBrains/Toolbox/apps/IDEA-U/ch-0/183.5429.30/lib/jps-launcher.jar;C:/Program Files/Java/jdk1.8.0_202/lib/tools.jar;C:/Users/t445857/AppData/Local/JetBrains/Toolbox/apps/IDEA-U/ch-0/183.5429.30/lib/optimizedFileManager.jar
2019-02-18 09:03:37,886 [ 320669] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
2019-02-18 09:03:37,886 [ 320669] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: Defaulting to no-operation (NOP) logger implementation
2019-02-18 09:03:37,886 [ 320669] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2019-02-18 09:04:08,556 [ 351339] WARN - .impl.LineStatusTrackerManager - Tracker release underflow by com.intellij.openapi.editor.impl.EditorImpl@5e2e119f

0
Comment actions Permalink

Joe,

Maybe it's possible to get logs from your colleague?

0
Comment actions Permalink

I don't know how long ago this happened for them, so it's probably fallen off their logs. I've let the team know to ping me if it happens again, and I'll let you know.

0
Comment actions Permalink

Joe,

Thanks for getting involved!

0

Please sign in to leave a comment.