ERROR: Failed to harvest environment variables

Setting up Unreal Engine 4 project files...
Binding IntelliSense data... 100%
Writing project files... 0%
UnrealBuildTool Exception: ERROR: Failed to harvest environment variables

GenerateProjectFiles ERROR: UnrealBuildTool was unable to generate project files

Press any key to continue . . .

This is the error I get after running setup and trying to generate the project files using the latest master branch. I tried the latest promoted but same error as well… Ran the file as normal and with admin rights. I have compiled from source before and this is a new error to me.

Any ideas?

EDIT: And now it works?

I deleted the folder and started over. This time I made sure I ran the setup and generateprojectfiles as admin the first time (I dont think I did that the first time the last time) and it had no issues… yay for a bug I can’t reproduce.

EDIT2: I take it back it is still broken, I checked out release instead of master is why it was working without issue.

EDIT3: Fixed in the latest pull from master branch, thanks Steve Robb!

I had this error before, make sure there aren’t any strange characters in the folder where your engine is located.

Current folder is “D:\Unreal Engine\master” so that shouldn’t be an issue =( I have had the older pre 4.8 master branch compiled in here as well at one point so this is just weird.

Weird maybe there is some kind of lingering setting in that folder that’s messing with it. Have you tried going through the motions and running generate project files in a different folder just in case?

Same error here…

I did a clean reinstall and pull and still the same issue. I am trying it now on another drive and in another folder and will see what happens this time. I am starting to suspect it is either using Windows 10 or using VS Community 2013 as the issue but it honestly seems highly unlikely. These are however the only changes I have to this system since the last time I did this.

Hi all,

Anyone who is having this problem - could you please inspect your user Temp directory - likely to be something like [FONT=Courier New]C:\Users<myusername>\AppData\Local\Temp and see if you have a couple of matching .tmp and .tmp.bat files, e.g.: [FONT=Courier New]tmp1234.tmp.bat and [FONT=Courier New]tmp1234.tmp. These are the files which harvest and contain your harvested environment variables respectively.

It’s possible that the .tmp file is either empty or malformed in some way. If you could post the details here, that would be great!

Also, if the .tmp file is empty, try running the .bat file directly and see if the .tmp file suddenly becomes populated. We have seen this before when dealing with systems containing large numbers of environment variables.


Bam figured out the problem, see if you can spot the problem in this batch file.

call C:\PROGRA~2\MICROS~1.0\Common7\Tools…\VC\bin\X86_AM~1\VCVARS~1.BAT store
D:\Unreal Engine\master\Engine\Binaries\DotNET\EnvVarsToXML.exe f: emp mp6E37.tmp

The call to the .exe file is not enclosed in “” due to the space in the folder name so it fails to run.

Can rename the folder as a temp fix for now and hopefully an actual fix will get checked into code in the future =)

I’ve submitted a fix for this:

I’ll try and get it into a future hotfix - it’s just missed 4.8.1 which has gone live.


And this is why there are so many of us using UE4 =) The support cannot get any better!

This was merged on master?

As far as I can tell it is indeed merged in master and the latest promoted branch. I pulled down master after the update, which pulled down updated required files, and re ran the generate project files with the problematic directory name and it worked without issue.

Is there a work around for this since it missed 4.8.1? It seems that the batch file is choking on my system path environment variable. EX: \Microchip\xc32\v1.21\bin";"C:\Program was unexpected at this time.

Right now I’m going through and cleaning that environment variable up, and hoping that’s all that it needs.

Edit: finished cleaning up path variable and I still get:
“\Microchip\xc16\v1.11\bin”;“C:\Program was unexpected at this time.”
even though this section is:
“C:\Program Files (x86)\Microchip\xc16\v1.11\bin;C:\Program Files (x86)\Microchip\xc8\v1.20\bin”

So I can’t use Unreal Engine for C++ projects now until I can get/figure out a work around or until next path/release.

Edit: Thought I had already scrubbed a Path in my User variables, that had the last remaining double quotes. Appears to work now.

Hey guys,

May have just found one solution to my source of the problem - it might not work for everyone, but it worked for me.

I too was getting the fabled error…

UnrealBuildTool Exception: ERROR: Failed to read environment variables from XML file: C:\Users\Alex.Stevens\AppData\Local\Temp	mpED32.tmp

So I ran tmpED32.tmp.bat in terminal, and noticed the extra quotation mark (shown in red, second last line - glad I was wearing my glasses).

C:\Users\Alex.Stevens>C:\Users\Alex.Stevens\AppData\Local\Temp	mpED32.tmp.bat

C:\Users\Alex.Stevens>call "D:\Program Files (x86)\Microsoft Visual Studio 12.0\
\Skype\Phone\ was unexpected at this time.
C:\Users\Alex.Stevens>  @set "PATH=C:\Program Files (x86)\Microsoft SDKs\Windows
\v8.1A\bin\NETFX 4.5.1 Tools\x64\;C:\cygwin64\bin;C:\Python27\Scripts;C:\Python2
7\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\ProgramData\Oracle\
Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\i
CLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\S
ystem32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engin
e Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IP
T;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Prog
ram Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files
 (x86)\QuickTime\QTSystem\;C:\Program Files\Common Files\Autodesk Shared\;C:\Pro
gram Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Windows K
its\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft SDKs\TypeS
cript\1.0";C:\Program Files (x86)\Skype\Phone\;D:\Program Files (x86)\Perforce"

For some reason, this added quotation mark has been added to the Global “PATH” environment variable. This was on my work laptop, so it might be a stuff-up from the Active Directory/IEM scripts distributing Skype, but it could be from the Microsoft SDKs… not 100% sure (without confirmation).

It might not be the same exact location for you, so look for a single quotation mark in your PATH System Variable and remove it - ** here be dragons, keep a copy of the whole PATH environment variable, just in case you break your windows.**


The bat file does not exist in my temp folder. Where can I get the code for the .bat? Does Unreal generate it at some point?

And why is a file required for the compiler to run properly located in a temp folder?

I had the same issue, I think there may be a maxlength on the Path variable.

I have the same problem as the original post person
My temp file is empty what does that mean? What do i do? And please keep it stupid im a very beginner level programmer that’s trying learn game development in Unreal

Hi All

I’ve the same problem with c++ project, checked all the tmp and PATH but found nothing wrong, check the message below:

An error occurred while trying to generate project files.

Running D:/Unreal/Epic Games/4.10/Engine/Binaries/DotNET/UnrealBuildTool.exe -projectfiles -project=“D:/Unreal/UnrealProjects/cppiu/cppiu.uproject” -game -rocket -progress -2015
Discovering modules, targets and source code for game…
UnrealBuildTool Exception: ERROR: Failed to harvest environment variables

same problem here please epic games fix it

@RiccardoLasagno and @SteakBoy: I have seen the same issue on Windows 10, UE 4.10.4. My temporary solution was to add admin rights to the editor (therefor for the launcher too). It works perfectly now.