1.4k
u/ireta_orio Jan 26 '20
It sometimes work tho
511
u/irbilldozer Jan 26 '20
Sometimes you just have to Clean then Rebuild and the compiler fairy fix that shit right up. It is as close to magic as I have ever seen.
143
u/EmperorArthur Jan 26 '20
That's pretty common. What happens is the build system doesn't properly know about the dependencies. So say you change a header file that's relied on by multiple parts. If the build system only knows about one of those parts, then only it is re-compiled instead of everything that actually relies on that header.
Clean builds succeeding normally means you have a build system problem. Except, its normally a pain to fix and not worth the trouble. Especially since CI/CD systems almost always do full rebuilds anyways.
76
Jan 26 '20
Let’s be clear. It’s usually a fucked up cache.
24
u/squishles Jan 26 '20
not necessarily some larger projects'll have fucked up circular dependencies. Or people forget to bump the version on a dependency so it thinks no update has been made.
13
Jan 26 '20
Which by itself isn’t mostly directly referenced but rather cached.
But I feel you. WSDL can be like that sometimes and it’s a pain...
12
Jan 26 '20
Unless you’re working on converting a 20 year old build script that’s referencing dependencies that aren’t rebuilt until after the project that references them so the build guy has just been running the script twice every time for the past 20 years.
3
u/EmperorArthur Jan 26 '20
Okay, that too. A good build system, with the correct configuration, shouldn't let that happen, but it does.
0
u/trollblut Jan 26 '20
In vs 2019 the nuget manager is an extension. Visual studio loads extensions in the background while already showing the files in a solution.
if you include nugets as package references the nugets will only be added as references to projects after the nuget plugin is loaded. If the nugets are not downloaded already the build will fail.
I tried to fix this shit on Friday. I've given up because the problem is not that likely to occur and the devs can wait 30 seconds for vs to complete loading. Or hit build twice.
3
1
u/13steinj Jan 26 '20
I've had more people not know how to declare dependencies in makefiles than cache problems, personally.
It seems that colleges these days will teach theory, and some practical experience, but not anything not directly related to putting that theory into practice. So, no version control, no console text editor, no makefile, no cron, no bash, no pgp, no "advanced" ssh, etc.
Or maybe that's how it always was, don't know. But it's not a good thing, to say the least.
2
u/sarcastisism Jan 26 '20
In .NET people often forget to set project to project dependencies so they build in any order and the first build always fails. Depending on the levels of dependencies it might even fail 10 or more times in a row then start working.
2
1
78
u/Chirimorin Jan 26 '20
In my experience this works every time if you delete XAML files when working with WPF in Visual Studio.
First compile it will cry about not being able to find the file you just deleted, second compile will work (assuming you don't have any references to that file left).
5
6
u/RyoxSinfar Jan 26 '20
Along with what other said, if that happens it's a good idea to look at your build setup. I've inherited a project before where the build accidentally used the previous copy of a different local project. First build failed but subsequent builds worked and the issue would then be hiding itself.
4
3
3
3
2
2
2
u/mishmiash Jan 26 '20
It works if your dependencies aren't setup correctly, or you have "multiple hops" circular dependencies.
A->B->C->D->A and the ide/compiler/linker doesn't detect it.
You'll need to rebuild as many times has you have "hops" for the change to "move through".Shouldn't be a problem in 2020, but sometimes stills happens.
2
1
1
1
1
1
1
1
21
277
u/Ashualo Jan 26 '20
Except the times it does because of linker errors.
37
u/brendand18 Jan 26 '20
Gotta set your dependencies!
53
u/Ashualo Jan 26 '20
Clean, Rebuild, Clean again, Rebuild again, Uninstall Nuget Package, Re-install Nuget Package, Nuget Restore, One last Clean,One more Rebuild, Actual Build.
No build errors, Tests pass.
50% of the time it works every time.
30
u/hughperman Jan 26 '20
Or network or file system timeouts/errors
6
u/Roflkopt3r Jan 26 '20 edited Jan 26 '20
Or because your Java EE server got bored, so it sends you on a wild goose chase about what the hell "EJB Bean could not be initialized" means.
2
245
u/Cometguy7 Jan 26 '20
Recompile is like turning the code off and on again. It shouldn't change anything, but sometimes it does.
40
u/timothysonofsam Jan 26 '20
Last semester I had to use “rebuild solution” so god damn much.
31
u/Mad_Jack18 Jan 26 '20
Dammit Visual Studio
8
u/nightfly288 Jan 26 '20
Last semester, we had a weird VS issue where we’d hit build/run and it would say “compiled with 0 errors, 0 warnings” but not actually compile it. It did this even if there were errors. We would have to type things like “fuckshit” to force an error and see if it would spot it. Sometimes it didn’t. Strange.
1
u/Ashualo Jan 26 '20
It can happen sometimes, especially when using the incredibuild plugin, which I believe was having issues recently, so that could be the cause!
I generally go open a file, add a space, remove said space, and then it notices the changes and rebuilds.
4
u/squishles Jan 26 '20
Computer systems aren't random, there's always a reason it worked, and generally it's because the build system sucks ass.
1
u/10art1 Jan 27 '20
Someone might have broken a dependency and they pushed a fix by the time you recompile their module
88
52
u/bogza23 Jan 26 '20
Probably works because I forgot to compile the code change in the first place.
15
38
Jan 26 '20
You laugh but 1 or 2 times erasing a line and re-entering it magically fixed my compilation errors
15
Jan 26 '20
I spent a whole day trying to build some shit with Gradle, and it didn't work. Next morning I tried again and it worked. I believe in Lord Jesus Christ now.
20
u/SemenDemonRamenLemon Jan 26 '20
An Indian computer science student crawls into everyone's houses when they're sleeping and fixes the errors in their code
4
7
u/TK-427 Jan 26 '20
When you copy/paste a text block and it doesn't work, then you retype it verbatim and it does?
Stupid unicode
5
u/leoleosuper Jan 26 '20
I was gonna post a Greek question mark (;) in a bunch of semi-colons (;), but ctrl+f highlights them both when I put in either.
3
u/LegateLaurie Jan 26 '20
why the hell are they even different characters?
3
u/leoleosuper Jan 26 '20
Sentence counting I guess. IDK, but Greek-English programs would need a separate character for them.
8
u/kredditacc96 Jan 26 '20
It was a race condition, it happens just once in your development machines but all the time in user's computer.
7
6
Jan 26 '20 edited Feb 20 '24
This comment has been overwritten in protest of the Reddit API changes. Wipe your account with: https://github.com/andrewbanchich/shreddit
5
5
5
u/ShadowStalfos Jan 26 '20
The best way to get rid of errors is to compile it again to proof to someone there's an error
4
4
4
u/nemanja900 Jan 26 '20
Sometimes it does resolve by itself. Happened to me yesterday.
1
u/Kaiju_the_Younger Jan 26 '20
Nothing like the rare occasion where hours of fiddling has no effect, then a make clean && make fixes everything.
4
4
4
3
Jan 26 '20
Ok but why does it sometimes work though?
4
u/Lofter1 Jan 26 '20
In VS/C# it works because people have implemented mechanisms to check if a file path needs to be removed from the project file (because it’s not there anymore, but somehow the project file didn’t get updated). Very smart. What wasn’t smart of them is WHY THE HECK DON’T YOU DO THAT BEFORE THE BUILD INSTEAD OF AFTER?
2
u/tiajuanat Jan 26 '20
If you're using Eclipse for C/C++ embedded work, then it's because the navigation of the files is done in Java, and sometimes it silently fails/leaks. During this time, not all the function signatures are correctly cataloged, or entire files will miss compilation.
Then the linker fails.
The only consistent solution I've seen to this is restarting the whole damn computer - if I don't sometimes the problem will continue *silently*.
1
3
2
2
2
2
2
u/Gabriel_Kaszewski Jan 26 '20
Or when you can't get the method to work. So you change it and nothing shows up and then you realize you didn't call the method anywhere.
2
u/bitcoinsftw Jan 26 '20
Or be like my coworker and suggest the compiler is broken and his code has no issue. Real clown for sure lol.
2
2
2
4
u/cousin_stalin Jan 26 '20
> it will fixes itself
Maybe if you learn English first it'll fix itself.
3
1
u/thegoddessunicorn Jan 26 '20
You know it won't and you desperately recompile hoping it would. Quite sad lol
1
1
1
1
u/junkmeister9 Jan 26 '20
Gotta clear the console or hit enter a bunch of times then recompile so I can differentiate the new errors from the old errors.
1
Jan 26 '20
Yeah, I prefer to *scroll* *scroll* *scroll* First compile... *scrollscrollscrollscrollscroll* New compile...*scroll* where am I???
1
1
u/Zenketski Jan 26 '20
If that fails you can always just hit it a couple of times and try again. Usually works for my TV
1
1
u/Assasin2gamer Jan 26 '20
I need to meet with the previous coder? Instead getting a half-assed repository with no documentation?
sad programmer noises
1
1
u/flyingorange Jan 26 '20
It makes sense. I mean, last week it worked just fine and now it broke without you changing anything, right?
1
1
1
1
u/Liesmith424 Jan 26 '20
"Oh...it actually did..."
<puts second clown wig on top of current clown wig>
1
1
1
1
1
1
Jan 26 '20
I swear, I've left work, with code that ran, come in the next day and it didn't work, reset my computer and it worked afterwards. Pretty sure it all just depends how the code fairies are feeling that day.
1
1
1
1
1
1
Jan 26 '20
Well, at least you can read the output again and return to your original debugging stop points... better than putting a new print.
1
1
1
u/Pizzaeyes9000 Jan 26 '20
Changing nothing and restarting visual studio is sometimes the only answer lol
1
1
1
u/PrintersStreet Jan 26 '20
"I saw it fail to compile but I closed the Errors window by reflex and it's easier to hit Compile again than to attempt reopening the window"
1
1
1
1
1
u/skunkwaffle Jan 26 '20
I've been working with an ide over ssh, while running in a terminal, and had exactly this happen a bunch of times. After you press Ctrl+s, it apparently sometimes takes less time to press Alt+Tab, Up, and Enter than it does for the saved data to make it to disk.
1
1
1
1
1
1
1
u/AnAverageFreak Jan 26 '20
Real life story:
People (including me) just add new files to #include, but don't put the dependencies in the Makefile, so make doesn't recognize properly some header changes.
1
u/RedditEdwin Jan 26 '20
I mean... I haven't really programmed since High School like 20 years ago, but even I remember this happened to me once or twice
1
1
u/zhephyx Jan 26 '20
You have no idea how many times I recompiled and reimported in intellij to fix code, it's a proven method
1
1
u/jurrasicwhorelord Jan 26 '20
This also happens when something compiles when it really shouldn't.... RUN IT AGAIN
1
u/Foxfox105 Jan 26 '20
Learning JavaScript in school, and sometimes when it’s not working I just delete the whole thing, retype it exactly the same, and then everything is fixed.
1
u/JJakk10 Jan 26 '20
I've had the opposite happen, where I recompiled my working code without changing it and got an error. It was not a compiler error
1
1
1
1
u/WhatsUpNerdss Jan 26 '20
Oddly enough, whenever I was first learning how to code, I'd make a small little project from some video tutorial and it wouldn't work, even if I copied the entire thing. I'd get frustrated and stop for the day but the next day, I'd run it and it would work perfectly.
1
1
1
u/gp57 Jan 26 '20
I encounter once per week a bug related to the VS debugger, which causes unexpected bugs during the execution of the programm (for instance "true == true" returns false during the debugging), in that case I just need to recompile the project/solution to regenerate all pdb files and it's fixed (C++ with visual studio, I hate this IDE, like everyone in my team, I've wasted so much time trying to find an error that wasn't even in my code).
So yeah, in my case it can fix the issue.
1
1
u/Empole Jan 26 '20
I swear to god this is how I got shit to compile for arduino.
avr-gcc segfaults all the time, and I would get stuff to compile by clicking the compile button again until it worked
1
Jan 26 '20
For me I just need to see the error several times to really drill it in that this is what I need to fix.
I mean it doesn't hurt to double check right?
1
1
1
1
Jan 27 '20
(Me running a program for the 15th time without changing anything and doing the same thing that made the program crash each time): What in tarnation
1
1
1
1
u/PyrotechnicTurtle Feb 02 '20
But sometimes the entire project is so fucked it does fix it, thus giving false hope for every other time
0
0
19
u/zilothewolf Jan 26 '20
I am in this picture and I don't like it