Build --> Rebuild Project randomly works

I recently started encountering infuriating behavior on my machine (briefly alluded to in a previous post ).

Doing Build --> Rebuild Project on my machine just started failing two days ago, after working for weeks without a problem. The build error error message textarea claims that idea is not finding all kinds of packages, but I can manually see files from those packages on my file system. I have no idea why this is happening: never seen it before, no one else on my team has this problem on their machines.

Yesterday, I manually deleted the entire project directory hierarchy and resynched from svn. The first time I tried Build --> Rebuild Project it worked, and I thought that this behavior was over. But I was mistaken: Build --> Rebuild Project randomly fails.

Anyone ever seen anything like this before?

Here is a detailed accounting of all the things that I did:

1) gutted my svn project directory and resynched

2) tried Build --> Rebuild Project; it worked normally.

3) ran some ant targets. (Our team uses all kinds of ant scripts, both for compiling, junit testing, as well as other stuff. The ant compiling script is an alternative to Build --> Rebuild Project; it was written because it is needed, for instance, on our continuous build server. I always do a complete clean of the class directory when I execute the compile and test ant targets.) Everything worked: the compiling and junit tests all pass.

4) I noticed that a lot of things were missing in idea, such as my run configurations, so I restored my previous day's .iws file from a backup. Now Build --> Rebuild Project failed again with the same nonsense missing package errors.

5) Guessing that that previous .iws file must be corrupt and so be the cause of all my problems, I tried deleting it, shutting down idea, and restarting idea (which generates a fresh .iws file if none is there). But Build --> Rebuild Project failed again with the same nonsense missing package errors. So, that previous .iws file cannot be the culprit.

6) tried steps 1) thru 3) again; same behavior. But when I tried Build --> Rebuild Project after running the ant scripts, it failed again.

7) by this point I have wasted most of my work day on this problem. Before giving up on the day, I eventually tried another Build --> Rebuild Project. Now, for some inexplicable reason, it worked. But instead of taking maybe 3 or 4 minutes, it takes more like 30 minutes, with almost all of the time spent in the final step of "Updating caches". A final Build --> Rebuild Project again worked, but again took forever.

8) today, first thing I do is try Build --> Rebuild Project twice in a row. Now, both times it completes in the usual 3 minutes or so.

9) then I ran my ant scripts; they work fine.

10) then I retry Build --> Rebuild Project; it fails the first 2 times with the same nonsense errors. The 3rd time it works normally. I did nothing in between!

My guess for the cause is that it has something to do with idea's caching. The sometimes taking forever to update the caches is what clued me in to this. The fact that the ant scripts, which use no caches, always work regardless of whether or not Build --> Rebuild Project works is consistent with this.

I have observed that when I execute the ant script to clean/compile/junit, that after ant has started gutting the class directory, I see idea reparsing files. Maybe sometimes it gets confused. But what is strange is that it always seems to be the SAME packages that idea thinks are missing (not all of them, just a subset). Of course, this could also be because these packages are what always pop up because of the build order failing on them first.

Something else is worthy to note: often when I try to execute Build --> Rebuild Project, the first attempt fails with an error dialog that says something like
"Failed to create directory ..."
where ... is a subdirectory in my classes directory. A second attempt to Build > Rebuild Project always gets this past this step. I have been seeing this error message for at least a week or more nowlong before the problems described above--so it may be a red herring.


Please sign in to leave a comment.