- Home /
Error building a Unity Linux app through Cygwin
I've made a small bash script in Cygwin for building my Unity project.
When I do that, curiosities arise.
This is my command:
$ "/cygdrive/c/Program Files (x86)/Unity/Editor/Unity.exe" -batchmode -nographics -projectPath "C:\Users\user\git\sandbox\game\Rainbow" -buildLinux64Player "C:\Users\user\git\sandbox\game\.build_linux/rainbow" -quit -logFile buildlog.txt
When I run this through Cygwin, it fails. When I run this through a Windows command shell (with the Unity.exe windows-path) everything works fine.
This is an excerpt of the errorlog, which holds the error:
- starting compile Library/ScriptAssemblies/Assembly-CSharp-firstpass.dll, for buildtarget 24
Could not start compilationArgumentException: Key duplication when adding: TMP
at System.Collections.Hashtable.PutImpl (System.Object key, System.Object value, Boolean overwrite) [0x00137] in /Applications/buildAgent/work/3df08680c6f85295/mcs/class/corlib/System.Collections/Hashtable.cs:831
at System.Collections.Hashtable.Add (System.Object key, System.Object value) [0x00000] in /Applications/buildAgent/work/3df08680c6f85295/mcs/class/corlib/System.Collections/Hashtable.cs:474
at System.Collections.Specialized.ProcessStringDictionary.Add (System.String key, System.String value) [0x00000] in <filename unknown>:0
at System.Diagnostics.ProcessStartInfo.get_EnvironmentVariables () [0x00000] in <filename unknown>:0
at UnityEditor.Scripting.ManagedProgram..ctor (System.String monodistribution, System.String profile, System.String executable, System.String arguments, Boolean setMonoEnvironmentVariables) [0x000c5] in C:\BuildAgent\work\812c4f5049264fad\Editor\Mono\Utils\ManagedProgram.cs:36
at UnityEditor.Scripting.Compilers.MonoScriptCompilerBase.StartCompiler (BuildTarget target, System.String compiler, System.Collections.Generic.List`1 arguments, Boolean setMonoEnvironmentVariables) [0x00024] in C:\BuildAgent\work\812c4f5049264fad\Editor\Mono\Scripting\Compilers\MonoScriptCompilerBase.cs:30
at UnityEditor.Scripting.Compilers.MonoScriptCompilerBase.StartCompiler (BuildTarget target, System.String compiler, System.Collections.Generic.List`1 arguments) [0x00000] in C:\BuildAgent\work\812c4f5049264fad\Editor\Mono\Scripting\Compilers\MonoScriptCompilerBase.cs:20
at UnityEditor.Scripting.Compilers.MonoCSharpCompiler.StartCompiler () [0x00102] in C:\BuildAgent\work\812c4f5049264fad\Editor\Mono\Scripting\Compilers\MonoCSharpCompiler.cs:35
at UnityEditor.Scripting.Compilers.ScriptCompilerBase.BeginCompiling () [0x00016] in C:\BuildAgent\work\812c4f5049264fad\Editor\Mono\Scripting\Compilers\ScriptCompilerBase.cs:40
(Filename: /Applications/buildAgent/work/3df08680c6f85295/mcs/class/corlib/System.Collections/Hashtable.cs Line: 831)
- Finished compile Library/ScriptAssemblies/Assembly-CSharp-firstpass.dll
Compilation failed because the compiler couldn't be executed!
Now, Cygwin has a "run" command, which runs a Windows command through Cygwin. If I run the command through here, it also works!
The only problem is, that run returns immediately, so my build script can't wait for it.
Run has an argument -wait, which makes run return only when the execution is done.
Only problem is, when I apply the -wait argument as specified in the manual:
$ run "/cygdrive/c/Program Files (x86)/Unity/Editor/Unity.exe" -wait -batchmode -nographics -projectPath "C:\Users\user\git\sandbox\game\Rainbow" -buildLinux64Player "C:\Users\user\git\sandbox\game\.build_linux/rainbow" -quit -logFile buildlog.txt
I get the same error.
The error looks to be something regarding a path or strings, but I am not sure why the -wait parameter would make this go bad.
Regards
I sort of gave up, but @jester23's answer seemed to make sense to me. $$anonymous$$aybe that can help you.
Answer by jester23 · Aug 03, 2013 at 12:59 PM
The problem is caused by the already set environment variables of cygwin. Haven't checked all the details, but "echo $TMP" should show that TMP is set and with "unset TMP" you should overcome this error.
Longterm solutions should be in the hands of the mono developers, but I think its rooted in the quite old version of mono used for unity.
cheers
Answer by sebtoun · Jul 07, 2017 at 02:01 PM
I noticed that when TMP is unset, Unity builds either :
produce an empty folder in project named something like
''$'\340\246\210\343\216\224\347\277\274'
(displayed as ঈ㎔翼 in explorer)pop up a "Power Shell has stopped working" message dialog.
In either case, the project is successfully built but I find it inconvenient to have garbage folders that need cleanup once in a while.
If the TMP variable is set (to /tmp), the "Key duplication when adding: TMP" error prevents build to succeed.
Has any one encountered this issue ? (and maybe solved it)
I am on Windows 10 in a git-bash (MSYS2) environment, using zshell and Unity 5.6.1