boocs / ue4-intellisense-fixes

Automatically fixes VSCode/Unreal Engine Intellisense Config bugs on startup
MIT License
162 stars 9 forks source link

** Error **: This fixable project hasn't been initialized properly and is invalid. #19

Closed shanataru closed 2 years ago

shanataru commented 2 years ago

Hello, I have installed this extension through VSIX and enabled the fixes as stated in the readme. I have not touched the original _c_cppproperties.json or _compileCommandsDefault.json.

I am moving from Visual Studio to VS Code, so I had to regenerate project files after setting the source code IDE to Visual Studio Code in UE (and after deleting folders: Immediate, Saved, Binaries and *.sln files).

I am using UE 5.0.2 and the extension version is 3.1.0 but no matter how many restarts and re-generating I do, I keep getting these errors:

Searching for *.uproject file...
Searching with fast-glob found nothing. (Sometimes isn't bug)
*.uproject file was found!

Extension "UE Intellisense Fixes" 3.1.0 is now active!

Found Unreal Engine v5.0.2

** Error **: This fixable project hasn't been initialized properly and is invalid.

** Error **: Couldn't create file watchers!

*** Number of error messages: 2
*** Number of warning messages: 0
If you get any errors you can try restarting VSCode to check if they've been fixed.

Extension is done.

I can build and run the code, the only problem is that header files are not being recognized (#include errors detected...). Is there a way to fix this?

Thank you in advance!

boocs commented 2 years ago

When you open your project do you have (Workspace) in the titlebar? Like so: image

If not, you need to double click on the ProjectName.code-workspace project file, in your project directory, to open the project as a workspace.

If you are opening it as a workspace I should be able to release an extension version that helps narrow down why you're getting the error. It might take a few releases to help narrow down the problem though.

Something else you can check. Can you create a new test project and check if that errors as well? What OS are you running?

shanataru commented 2 years ago

Hi again, I have the workspace titlebar enabled, I am opening the VS Code as you said so the project should start properly. I am working with an archvis project (if it's relevant) - I first create the project, then create a c++ class, which then opens in the IDE. The error persists - Intellisense just does not work and I have the aforementioned errors. Even closing and re-opening via code-workspace does not help. I am working on Windows 10.

boocs commented 2 years ago

I released 3.1.1.

It probably wont fix your bug but will add error messages to point me in the right direction. Let me know if you see any new error messages in the logs.

I'll still have to update the extension again till I can find the reason your project is invalid.

shanataru commented 2 years ago

Hi and thank you, here's the new error message with the released version 3.1.1

** Error **: Error in loadCompileCommandsFromWorkspace!
boocs commented 2 years ago

I updated the extension again to get more error messages. Let me know what new ones pop up. Thanks!

shanataru commented 2 years ago

Error in v3.1.2:

** Error **: 0: Couldn't create compileCommands from D:\Unreal Projects\RT_ToolStack\.vscode\compileCommands_Default.json with key:MAIN! (not an error with UE 4.25.#)

** Error **: Did not create any compile commands with keyMAIN! (not an error with UE 4.25.#)

My _compileCommandsDefault.json is pretty much empty with only brackets [ ]

boocs commented 2 years ago

Do you have any .cpp or .h files in your Source/ProjectName directory?

Make sure compileCommands_Default.json isn't read only or protected somehow.

Try to Generate Project Files again to see if this fixes this file. How are you Generating Project Files? Can you try other ways? I think there are 3 ways total.

If that doesn't works try right clicking on your project's *.uproject file and choose Switch Engine Version and choose the same engine version and hit ok. Does that work?

shanataru commented 2 years ago

Hi,

I have ProjectName.Build.cs, ProjectName.cpp and ProjectName.h in my Source/ProjectName directory. _compileCommandsDefault.json is not specially protected or read-only.

I tried to generate with the .uproject (right click - Generate Visual Studio project files). I also tried through shell running UnrealBuildTool:

.\UnrealBuildTool.exe -projectfiles -project="Path_To_Project/ProjectName.uproject" -game -rocket -progress -engine -VSCode

I tried to refresh Visual Studio Code from the UE editor. I do not know the third way to generate project files.

Switching to the same version did not work either.

Maybe you can test it out at your local machine with the archvis project as I did above? I might just be doing something silly.

Thank you

boocs commented 2 years ago

Ah so the ArchVis project is a Blueprint project by default.

I can't test this currently since this computer can't run UE5. My UE5 computer arrives tomorrow and I'll have to build it. I can test this in 4.27 though. It'll probably be the same.

boocs commented 2 years ago

With 4.27 it worked. I created a trafic light actor from the editor's C++ class creator.

4.27 did create a projectname.h and projectname.cpp automatically when creating this actor.

Everything works with 4.27 and intellisense. If this doesn't apply to UE5 then let me know. I'll have to retest it either tomorrow or Friday in UE5.

shanataru commented 2 years ago

Hi, I did not create the ProjectName.h and ProjectName.cpp manually, it got created automatically after I created a new c++ class from the UE editor. It prompted that the project now includes sources and that a build from IDE is needed. Then the IDE is opened with generated .h and .cpp. I restart the IDE and open the .code-workspace. Still same errors.

I have tried it in 4.27 (archvis, same steps) and it works for me, even Intellisense works. It most likely have something to do with UE5.

boocs commented 2 years ago

There should be another compileCommands_ProjectName.json in the .vscode directory.

shanataru commented 2 years ago

Only this is in the .vscode directory, _compileCommandsDefault directory is empty:

image

I do not know if it's relevant but this is the .vscode in the UE5 dir:

image

boocs commented 2 years ago

Very strange.

I'll check it out after my one part I'm waiting for arrives!

boocs commented 2 years ago

Unfortunately took longer as I thought it would.

It definitely is bugged. Pretty strange one.

I think there is a way to do it though but would require some work.

I'll try to test this to see if it works.

boocs commented 2 years ago

I'm sure it's possible but I haven't had any luck. I'll try something else.

shanataru commented 2 years ago

I'm sure it's possible but I haven't had any luck. I'll try something else.

Do you mean creating the project from a blank game C++ project did not work?

boocs commented 2 years ago

I was a little too negative. It actually does work if all you want is all the same plugins that are enabled in the default archvis project.

So that actually works. You can then create your own map.

Trying to migrate the archvis content/map was where I was having difficulty. But you don't need it if you're just going to create your own stuff.


To copy plugins list just open your archvis .uproject file in a text editor. Copy the plugins and paste them in a C++ project's .uproject file. There will be 2 plugins that are duplicates. One of the dupe plugins does have different options between the archvis and c++ projects. You can decide which dupe plugin you want to keep.

boocs commented 2 years ago

Also I was trying to migrate the entire map. If you want to migrate individual content then you might have better luck doing that. There might be some useful Blueprint you might want to migrate over to your C++ project.

shanataru commented 2 years ago

Thank you for your hard work. I suppose there is no other way around than to just use the Game C++ project? I will be using the migrating solution for now.

boocs commented 2 years ago

I was able to get the migration fully working which lead me to find out what was causing the problem.

The plugin DatasmithCADImporter is the cause of the bug. Pretty strange!

So to fix:

Note: You can fix an already created project by disabling the plugin as well.

If you need that plugin you can enable it briefly and then disable it after you import.

You should probably make a bug report about it.

shanataru commented 2 years ago

Oh noes, not this plugin again...

This is a great find though! Thank you so much for your help!

boocs commented 2 years ago

You can ignore this but it's a meme about message boards about someone telling that they figured something out but not explaining how they did it.

So here's how I migrated in case someone finds this:

Now you need to copy over the ini files found in the Config folder. You need to do this manually. You have to be careful. Some ini files can be copied fully, some need to be selectively copied. Here's how I did the ArchVis project ini files.

Copy all DefaultEditor.ini Copy all DefaultEditorPerProjectUserSettings.ini Copy all DeafultLightmass.ini

Inside DefaultEngine.ini:

[/Script/Engine.RendererSettings] Copied all settings(some settings are separated by spaces) and overwrote the settings already there

[/Script/EngineSettings.GameMapsSettings] Copied all settings and overwrote the settings already there

[/Script/UnrealEd.UnrealEdEngine] Created this category and copied all settings

[/Script/Engine.PhysicsSettings] Created this category and copied all settings

[/Script/Engine.CollisionProfile] Created this category and copied all settings

[/Script/WindowsTargetPlatform.WindowsTargetSettings] Copied all settings and overwrote the settings already there (If you're not on Windows, this setting's section name might be different)

[/Script/Engine.Engine] Copied all settings and overwrote the settings already there