# Error building a Unity Linux app through Cygwin

**URL:** https://discussions.unity.com/t/error-building-a-unity-linux-app-through-cygwin/68377
**Category:** Questions & Answers
**Created:** [April 11, 2013, 4:35pm UTC](https://discussions.unity.com/t/error-building-a-unity-linux-app-through-cygwin/68377 "2013-04-11T16:35:44Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Vicas](https://avatars.discourse-cdn.com/v4/letter/v/85f322/32.png) [@Vicas](https://discussions.unity.com/u/Vicas)
#### Post date: [April 11, 2013, 4:35pm UTC](https://discussions.unity.com/t/error-building-a-unity-linux-app-through-cygwin/68377/1 "2013-04-11T16:35:44Z")

</div>

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

---

<div class="post-metadata">

### Author: ![jester23](https://avatars.discourse-cdn.com/v4/letter/j/a183cd/32.png) [@jester23](https://discussions.unity.com/u/jester23)
#### Post date: [August 3, 2013, 12:59pm UTC](https://discussions.unity.com/t/error-building-a-unity-linux-app-through-cygwin/68377/2 "2013-08-03T12:59:41Z")

</div>

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

---

<div class="post-metadata">

### Author: ![sebtoun](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@sebtoun](https://discussions.unity.com/u/sebtoun)
#### Post date: [July 7, 2017, 2:01pm UTC](https://discussions.unity.com/t/error-building-a-unity-linux-app-through-cygwin/68377/3 "2017-07-07T14:01:51Z")

</div>

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
