After updating Unity Hub and loading any project with C# scripts in it, I noticed that there were blank compiler errors that wouldn’t go away, preventing the project from running or any of its scripts from being properly included.
Here’s a screenshot of the project right after adding the script:
That’s it. A blank error will now appear in the console log and will not go away until you delete the C# Script.
Investigation/Error Output
Double clicking on the blank Console Error does nothing.
I took a look at the Editor Log file (in the upper right tab of the Console → Open Editor Log) and found the following error at the bottom of Editor.log:
-----CompilerOutput:-stdout--exitcode: 9009--compilationhadfailure: True--outfile: Temp/Assembly-CSharp.dll
-----CompilerOutput:-stderr----------
'"C:\Program Files\Unity\Hub\Editor\2019.2.14f1\Editor\Data\Tools\RoslynScripts\..\..\Tools\Roslyn\csc"' is not recognized as an internal or external command,
operable program or batch file.
-----EndCompilerOutput---------------
- Finished compile Library/ScriptAssemblies/Assembly-CSharp.dll
I ran the program that the error supposedly said was not recognized (“C:\Program Files\Unity\Hub\Editor\2019.2.14f1\Editor\Data\Tools\RoslynScripts\…\…\Tools\Roslyn\csc”) in a Windows Command prompt, and it seems like this command IS in fact valid:
I tried uninstalling Unity and Visual Studio, removing all files I could find in the system that referenced Unity (I may have missed a few since Unity Hub somehow automatically logged me in after I reinstalled it), and rebooting my PC.
I also tried an older version of Unity, making a new project Unity Version 2019.2.13f1, a version that has worked on my PC before, but the same exact problem occured.
I fixed it! Albeit in a non conventional way. Not sure why this worked, but I think this fix can be applied to other problems found when getting blank errors.
Here’s exactly what I did:
(You should probably close the Unity Editor before doing this)
Go to “C:\Program Files\Unity\Hub\Editor\2019.2.14f1\Editor\Data\Tools\RoslynScripts”
Edit “unity_csc.bat”
Replace the line that says “%APPLICATION_CONTENTS%\Tools\Roslyn\csc” /shared %* with the following: “C:\Program Files\Unity\Hub\Editor\2019.2.14f1\Editor\Data\Tools\Roslyn\csc.exe” /shared %*
Reopen the same project in Unity and it should work.
I think if you just add an “.exe” to the end of the csc directory it should also work, but I also converted it into a full path anyways.
No clue why it worked, since you should be able to run executable commands without the “.exe” extension but I don’t know much about Batch so maybe the bat file itself has something to do with it.
Update to the accepted answer:
Fix: Go to C:\Program Files\Unity\Hub\Editor\2019.2.14f1\Editor\Data\Tools\RoslynScripts folder
Open the batch file in notepad and paste the following:
@ECHO OFF
set APPLICATION_CONTENTS=%~dp0..\..
echo host set to %APPLICATION_CONTENTS%
"C:\Program Files\Unity\Hub\Editor\2019.2.14f1\Editor\Data\Tools\Roslyn\csc.exe" /shared %*
exit /b %ERRORLEVEL%
Happend on 2018 4.0 with Win7, solved after installing Windows7 patch KB4457144, if anyone could not find folder “RoslynScripts” (mentioned in best answer), try this.
Hi !
I changed SSD drive and I installed win10. I’m using my project with 2019.1.7f1.After a working while, 4 blank errors appeared.
When i use my project with old drive, there is no blank errors!
When i updated to 2019.2.21f1 errors decreased to 2 errors.
I have been trying to solve this for days but couldnt get rid of this.
I followed suggestions @adrisj7 but none of them work.
I think the problem is about Win 10 (Microsoft Windows [Version 10.0.18363.657] )
Any suggestions?
Suddenly every project I opened, any version 2019 or above, or even creating a new project, had blank compile errors (anywhere from 2 to 89 such errors).
The only insight the editor log gave was that “Tundra build failed” with exit code 1, no reason given.
In investigating this, I found a seeming unrelated problem: I couldn’t open cmd.exe for some reason.
Guys i found the best way to get rid of that error…Just delete that file “unity_csc.bat” that works for me you will just get a tiny error that tells you “Ur editor files are corrupted?” just clear the console and ignore it ,but it really works so if you think its a bad idea just make sure to make a backup of that file.
For anyone with a similar issue on Linux. Debian Bookworm, unity version 2020.3.20.f1
I was getting a blank error and the console said “Fix all compiler errors before running” but as said the error was blank.
It turns out unity expects an older version of libicu, if this is not present the roslyn compiler will crash but Unity does not forward the crash stack trace to the console log, which makes the whole thing difficult to figure out.
The fix:
Install libicu67 from the previous Debian version.
You can also get around the compiler crash by setting the following environment variable (although I did not test running unity with this, and what this does is disable localization which I don’t know what localization would it disable):
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
potentially you could edit your /unityEditorLocation/Editor/Data/Tools/RoslynScripts/unity_csc.sh to contan an export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1