# Error when trying to create a new C++ Project. (Failed to generate project files)

**URL:** <https://forums.unrealengine.com/t/error-when-trying-to-create-a-new-c-project-failed-to-generate-project-files/310923>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [March 14, 2015, 10:49am UTC](https://forums.unrealengine.com/t/error-when-trying-to-create-a-new-c-project-failed-to-generate-project-files/310923 "2015-03-14T10:49:30Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![OfficialKHAN\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@OfficialKHAN\_1](https://forums.unrealengine.com/u/OfficialKHAN_1)\
**Post date:** [March 14, 2015, 10:49am UTC](https://forums.unrealengine.com/t/error-when-trying-to-create-a-new-c-project-failed-to-generate-project-files/310923/1 "2015-03-14T10:49:30Z")

</div>

Hi

below, you can see the error i am getting when i try to create a new C++ Project. Ive had this working before and this issue has only recently occurred with the latest update.

> Failed to generate project files. Log  
> output: Running C:/Program  
> Files/Unreal  
> Engine/4.7/Engine/Binaries/DotNET/UnrealBuildTool.exe  
> -projectfiles -project=“C:/Users/KHAN/Documents/Unreal  
> Projects/Training/Training.uproject”  
> -game -rocket -progress Discovering modules, targets and source code for  
> game… UnrealBuildTool Exception:  
> System.ArgumentOutOfRangeException:  
> Length cannot be less than zero.  
> Parameter name: length at  
> System.String.InternalSubStringWithChecks(Int32  
> startIndex, Int32 length, Boolean  
> fAlwaysCopy) at  
> UnrealBuildTool.Utils.SetEnvironmentVariablesFromBatchFile(String  
> BatchFileName) at  
> UnrealBuildTool.VCEnvironment…ctor(CPPTargetPlatform  
> InPlatform) at  
> UnrealBuildTool.VCToolChain.GetVCIncludePaths(CPPTargetPlatform  
> Platform) at  
> UnrealBuildTool.VCProjectFile.WriteProjectFile(List`1 InPlatforms, List`1 InConfigurations)  
> at  
> UnrealBuildTool.ProjectFileGenerator.WriteProjectFiles()  
> at  
> UnrealBuildTool.ProjectFileGenerator.GenerateProjectFiles(String  
> Arguments, Boolean& bSuccess) at  
> UnrealBuildTool.UnrealBuildTool.GenerateProjectFiles(ProjectFileGenerator  
> Generator, String Arguments) at  
> UnrealBuildTool.UnrealBuildTool.Main(String  
> Arguments)

TempAttachments

---

<div class="post-metadata">

**Author:** ![OfficialKHAN\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@OfficialKHAN\_1](https://forums.unrealengine.com/u/OfficialKHAN_1)\
**Post date:** [March 14, 2015, 10:58am UTC](https://forums.unrealengine.com/t/error-when-trying-to-create-a-new-c-project-failed-to-generate-project-files/310923/2 "2015-03-14T10:58:06Z")

</div>

This issue only occurs when you run the Epic Games Launcher through the steam client.

---

<div class="post-metadata">

**Author:** ![robert.manuszewski](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@robert.manuszewski](https://forums.unrealengine.com/u/robert.manuszewski)\
**Post date:** [March 16, 2015, 4:22pm UTC](https://forums.unrealengine.com/t/error-when-trying-to-create-a-new-c-project-failed-to-generate-project-files/310923/3 "2015-03-16T16:22:56Z")

</div>

Hi,

This looks like internal error when parsing environment variables set by vcvarsx86\_amd64.bat.

It would be extremely useful if you could locate and attach two temporary files created by UnrealBuildTool which are used to obtain those environment variables.

Both of these files are located in the temporary folder:

```
C:\Users\your.username\AppData\Local\Temp\tmp5E21.tmp.bat
C:\Users\your.username\AppData\Local\Temp\tmp5E21.tmp

```

tmp5E21 is something that’s not going to look the same on your machine (or even after each UBT run) but you should be able to find two most recent files that look similar in the temporary folder.

---

<div class="post-metadata">

**Author:** ![RCL](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RCL](https://forums.unrealengine.com/u/RCL)\
**Post date:** [March 16, 2015, 5:35pm UTC](https://forums.unrealengine.com/t/error-when-trying-to-create-a-new-c-project-failed-to-generate-project-files/310923/4 "2015-03-16T17:35:31Z")

</div>

What do you mean by running Launcher through Steam client? Launcher is not a Steam application.

---

<div class="post-metadata">

**Author:** ![OfficialKHAN\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@OfficialKHAN\_1](https://forums.unrealengine.com/u/OfficialKHAN_1)\
**Post date:** [March 16, 2015, 5:37pm UTC](https://forums.unrealengine.com/t/error-when-trying-to-create-a-new-c-project-failed-to-generate-project-files/310923/5 "2015-03-16T17:37:17Z")

</div>

@RCL You can add any application as a non-steam game. So you can run it through the steam library.

---

<div class="post-metadata">

**Author:** ![RCL](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RCL](https://forums.unrealengine.com/u/RCL)\
**Post date:** [March 16, 2015, 5:42pm UTC](https://forums.unrealengine.com/t/error-when-trying-to-create-a-new-c-project-failed-to-generate-project-files/310923/6 "2015-03-16T17:42:22Z")

</div>

Why would you do so? (for the launcher)

---

<div class="post-metadata">

**Author:** ![OfficialKHAN\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@OfficialKHAN\_1](https://forums.unrealengine.com/u/OfficialKHAN_1)\
**Post date:** [March 16, 2015, 5:46pm UTC](https://forums.unrealengine.com/t/error-when-trying-to-create-a-new-c-project-failed-to-generate-project-files/310923/7 "2015-03-16T17:46:57Z")

</div>

@RCL Steam library just a nice place to keep all the applications i use.I assume this isent possible then?

---

<div class="post-metadata">

**Author:** ![RCL](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RCL](https://forums.unrealengine.com/u/RCL)\
**Post date:** [March 16, 2015, 5:58pm UTC](https://forums.unrealengine.com/t/error-when-trying-to-create-a-new-c-project-failed-to-generate-project-files/310923/8 "2015-03-16T17:58:43Z")

</div>

I don’t think we tested such a scenario, but we don’t see an obvious reason for it to fail. I hope Core team (Robert) will help you narrow down the problem - I was just double checking that we properly understand what you were doing 🙂

---

<div class="post-metadata">

**Author:** ![RCL](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RCL](https://forums.unrealengine.com/u/RCL)\
**Post date:** [March 16, 2015, 6:05pm UTC](https://forums.unrealengine.com/t/error-when-trying-to-create-a-new-c-project-failed-to-generate-project-files/310923/9 "2015-03-16T18:05:15Z")

</div>

I don’t think we tested such a scenario, but we don’t see an obvious reason for it to fail. I hope Core team (Robert) will help you narrow down the problem - I was just double checking that we properly understand what you were doing 🙂

---

<div class="post-metadata">

**Author:** ![OfficialKHAN\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@OfficialKHAN\_1](https://forums.unrealengine.com/u/OfficialKHAN_1)\
**Post date:** [March 16, 2015, 7:50pm UTC](https://forums.unrealengine.com/t/error-when-trying-to-create-a-new-c-project-failed-to-generate-project-files/310923/10 "2015-03-16T19:50:23Z")

</div>

@robert.manuszewski

I have updated my initial question with a .zip folder containing the two files you require.

Just a quick question will UE4 ever be on steam officially?

---

<div class="post-metadata">

**Author:** ![robert.manuszewski](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@robert.manuszewski](https://forums.unrealengine.com/u/robert.manuszewski)\
**Post date:** [March 19, 2015, 1:39pm UTC](https://forums.unrealengine.com/t/error-when-trying-to-create-a-new-c-project-failed-to-generate-project-files/310923/11 "2015-03-19T13:39:45Z")

</div>

For some reason Steam stores a new line character in one of their environment variables and that breaks code responsible for parsing output in UnrealBuildTool. I submitted a fix to guard against that in master branch: [https://github.com/EpicGames/UnrealEngine/commit/99a3c70ff4c81249194bc7aa1693b50e048cb64b](https://github.com/EpicGames/UnrealEngine/commit/99a3c70ff4c81249194bc7aa1693b50e048cb64b)
