Unable to generate c++ projects file 4.9 *Found Fix*

When ever i try to generate c++ project files on 4.9.1 i get the error:

An error occurred while trying to generate project files.

Running C:/Program Files/Epic Games/4.9/Engine/Binaries/DotNET/UnrealBuildTool.exe -projectfiles -project=“D:/CGP/CGP/CGP.uproject” -game -rocket -progress
Discovering modules, targets and source code for game…
UnrealBuildTool Exception: ERROR: Failed to harvest environment variables

Looking into i found that the engine is creating the temp files but they are not been filled with any information,
This is a copy of the batch file

call “C:\PROGRA~2\MICROS~1.0\Common7\Tools....\VC\bin\X86_AM~1\VCVARS~1.BAT”
“C:\PROGRA~1\EPICGA~1\4.9\Engine\Binaries\DotNet\EnvVarsToXML.exe” “%~dp0%\tmp94E2.tmp”

I looked into a few fixes for similar problems such as making sure i have no spaces in my project file path and disabling my anti virus
My engine is in the same place as 4.8 apart from been in an 4.9 folder instead and i can create both blueprint and c++ projects fine on 4.8 ,

Thanks

EDIT: I Fixed managed to fix this problem by reinstalling the “Windows 8.1 SDK” i can now compile and build c++ projects on 4.9.1

Thank you for your help in trying to fix this error

Hi ,

I some quick tests and was unable to see the results that you described. Would you be able to provide more information about what you are doing/trying to do?

  • Are you using the binary version of the Engine installed by the Launcher?
  • Are you right-clicking on an existing .uproject file and selecting the “Generate Visual Studio project files” option?
  • Was your project upgraded from 4.8?
  • Are you able to create a new C++ project in 4.9.1?
  • What version of Windows and Visual Studio are you using?

Hey ,

Are you using the binary version of the Engine installed by the Launcher? : Installed by Launcher

Are you right-clicking on an existing .uproject file and selecting the “Generate Visual Studio project files” option? No Brand new project

Was your project upgraded from 4.8? No new project

Are you able to create a new C++ project in 4.9.1? No c++ project are the one giving me errors, i have no problem with making blueprints project but if i do i still cant add code to them

What version of Windows and Visual Studio are you using?
Windows 8.1 VS Professional 2013

Thanks,
Phil

Im having the same problem too been looking for a fix for a while i though 4.9.1 would fix it, cant create or have anything with code in it, fails every time, im using win7, vs 2013 community update 5, same conditions as above

I did the full verify with no errors but when i tried to run the two project after converting them to 4.9 both project threw these errors(see attached photo) when i tried to run them.

60095-errortest.png

I have not run into any problems either creating a new C++ project with the binary 4.9.1 Engine, nor with adding code to a Blueprint project. I have a few things for you to try.

First, in the Library section of your Launcher, please verify your 4.9.1 installation (this may take a few minutes).

If no problems occur with the verification (I don’t expect any), please download one (or both) of [these][2] [projects][3]. Unzip the project and right-click on the .uproject file. Select the “Switch Unreal Engine version” option, make sure it is set to 4.9, then click OK. Please let me know if you see the same error as before.

Also this is my output log when i try to add c++ code to an blank project

Please download this file and place it on your desktop. Remove the .txt extension and run the batch file. It will create a new file called info.txt that contains information about your Visual Studio installation. If you could please upload that here, that would be helpful.

Hi , im having the same troubles as mentioned before, running the verify didn’t help for me either. i attached my info.txt link text

Thanks for providing that, Colbra. At first glance, everything there appears to be fine. Could you try this again and this time, when the error occurs, don’t close the window. Instead, navigate to your temp folder (normally located at C:\Users\UserName\AppData\Local\Temp). Sort the folder with the most recent files at the top, and you should see two files with the same name: tmpXXXX.tmp and tmpXXXX.tmp.bat (“XXXX” will be replaced with a string of four characters). If you open the tmp file, I expect it to be empty (as mentioned in the OP). If you could, please zip and upload the tmp.bat file.

heres the ziplink text

nothing, just a quick open and close

No, its only there for really quick moment then gone

One more bit of information. What, if anything, happens if you run EnvVarsToXML.exe manually? You can find this at ..\Epic Games\4.9\Engine\Binaries\DotNET.

If you check the Processes tab of your Windows Task Manager, do you see any EnvVarsToXML processes still running?

Hey
Attached is my info.txt from the batch filelink text

I’ve got this problem too. UE4 is unable to do anything c++ related. Creating a new project, adding classes, nothing works. This goes for 4.9.1 as well as 4.8.3

Looking around, I’ve read that the batch file in AppData\Local\Temp is important. Running the batch file does nothing to the corresponding tmp file. It remains empty. However… my batch file has this line…
"call “C:\PROGRA~2\MICROS~3.0\Common7\Tools....\VC\bin\X86_AM~1\VCVARS~1.BAT”

If I change it so that it reads this…
call “C:\PROGRA~2\MICROS~3.0\Common7\Tools\VCVARS~1.BAT” (removing ....\VC\bin\X86_AM~1)
…then the tmp file will be filled with Environment Variables. Which I’m guessing it what SHOULD happen.

I removed that part of the path because I realised that VCVarsQueryRegistry.bat is located in… C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools.

So surely the batch file that UE4 is creating in my Temp folder is wrong isn’t it? Question is, how do I stop these batch files from being written incorrectly…?

I’m running the editor from Launcher by the way, always have.

Edit: Ok, so I’ve realised that in batch files, writing "\ . . " Is a way to get to the parent folder. Which means I’ve found vcvarsx86_amd64.bat that the AppData tmp batch file is referring to. What are the tmp file in the AppData supposed to look like? Should it be an XML with Environment Variables like I was getting?

Ok I think I’ve solved my issue. Let me know if it works for you guys…

I went here > ERROR: Failed to harvest environment variables - C++ - Epic Developer Community Forums
and saw the very last post.

Check out the picture that was posted, and follow the red arrows. Advanced System Settings → Environment Variables → Select “Path” → Edit…
Now copy the ALL the text which is inside “Variable value:” field. Paste that into Notepad or Notepad++. As the guy in that thread said, “keep a copy of the whole PATH environment variable, just in case you break your windows.”

Search (Ctrl + F) for double quote characters ("). If one of your paths is surrounded by double quotes, then that may be your problem. For me, I had a path which looked like this… “C:\Program Files (x86)\Microsoft DirectX SDK (August 2006)\Utilities\Bin\x86”

I removed the double quotes from that, and it worked. I can now create a new C++ project in 4.9.1.

I am getting the same results as Colbra where running EnvVarsToXML.exe only flashes up for just a second and isnt even running in the process tab after

Hi ,

Would you be able to post the solution that corrected this issue for you as an Answer? That way we can mark that Answer as having resolved the issue.

Colbra, could please try reinstalling your Windows SDK’s to see if it helps you as well?