## Build fails if LANG is set to a UTF8 locale

_Submitted by a community member on 2015-09-11 14:35 UTC_

I normally have set the LANG environment variable to de\_DE.utf8. However, this makes MonoDevelop (5.9.6 under Manjaro Linux 15.09) unable to start MSBuild process. Triggering a compilation yields the following error message in the build log:

Build failed. MSBuild process could not be started

I also see other strange behavior, e.g. "using System.Linq" higlighted red, although all assembly references are OK.

After some investigation, I found out, that the problem seems to be the Byte Order Mark (BOM), which is automatically generated for stdout and stderr in some cases and seems to be a problem for some inter process communications, as they redirect the stream output of a process and parse it, but don't expect the BOM at the beginning.

If I change the locale to de\_DE (without .utf8), everything is OK. This is my current workaround.

I wrote the following simple code (with some copies from MonoDevelop code) to investigate the problem. You may find is useful or ignore it:

using System;
using System.Linq;
using System.Diagnostics;
using System.Threading;

class P
{
```
  public static void Main(string[] args)
  {
    string responseKey = "[MonoDevelop]";
    var exe = "/usr/lib/monodevelop/bin/MSBuild/4.0/MonoDevelop.Projects.Formats.MSBuild.exe";
    var pinfo = new ProcessStartInfo (exe)
    {
      UseShellExecute = false,
      CreateNoWindow = true,
      RedirectStandardError = true,
      RedirectStandardInput = true
    };
```

```
    var process = new Process { StartInfo = pinfo };
```

```
    Console.WriteLine("Starting process " + pinfo.FileName);
    process.Start();
```

```
    process.BeginErrorReadLine();
    process.ErrorDataReceived += (sender, e) =>
    {
      Console.WriteLine("Received error: {0}", e.Data ?? "<null>");
      if (e.Data == null) return;
      if (e.Data.StartsWith(responseKey, StringComparison.Ordinal))
        Console.WriteLine("Response Key found!");
      else
      {
        Console.WriteLine(string.Join(" ", from c in e.Data.Take(responseKey.Length) select ((int)c).ToString("X")));
        if (e.Data.Substring(1).StartsWith(responseKey, StringComparison.Ordinal))
          Console.WriteLine("Response Key found at position 1!");
      }
    };
```

```
    process.StandardInput.WriteLine("0");
```

```
    Console.WriteLine("Waiting for finish");
    process.WaitForExit();
    Console.WriteLine("Finished");
  }
```

}

* * *

_Reference: <https://bugzilla.xamarin.com/show_bug.cgi?id=33896>_