boocs / unreal-clangd

VSCode extension for Unreal and clangd
59 stars 5 forks source link

Unable to read file `completionHelper.cpp` #2

Open andraghetti opened 1 year ago

andraghetti commented 1 year ago

HI! Thanks for sharing your amazing work!

I haven't manage to make it work tho. I installed it but this is what I see in the output. I'm working on a Mac with M1 and Unreal 5.2. I installed your extensions (not the intellisense one. Should I?), and I kept Microsoft C++ and C# and clangd.

I really would like to contribute to this repo helping filling the mac part if you would like to guide me.

** Error **: cannot open file:///MYPROJECT/.vscode/unreal-clangd/completionHelper.cpp. Detail: Unable to read file '/MYPROJECT/.vscode/unreal-clangd/completionHelper.cpp' (Error: Unable to resolve nonexistent file '/MYPROJECT/.vscode/unreal-clangd/completionHelper.cpp')

** Error **: The error above may not be an error. completionHelper.cpp will be created during creation process.

(redacted my project path with MYPROJECT)

boocs commented 1 year ago

You may be the only other person besides me using this lol. If you do get it to work it's pretty awesome. Been using it a lot recently. Unfortunately Mac/MacM1 wasn't tested for this extension.

  1. You shouldn't have my other extension enabled for the project you're using this on

  2. Have you run the extension's "Create Unreal clangd Project" command for your project?

andraghetti commented 1 year ago

It seems like a great tool, so I'm keen to make it work on Mac and help you improving the docs for Mac.

Oh! I haven't done that. Maybe it would be good to have a "Steps" section or something to start with the tool.

Anyway, I tried now and I got this:

Screenshot 2023-07-30 at 11 22 03

(could be good to have a troubleshooting section for this, or even an option to autofix? I guess you could ask the use to replace clangd files. Or am I wrong? I read that you warn the user to not install clangd with vscode, but there's no mention of a solution in case that has already been done before.

boocs commented 1 year ago

You can find the Doc links at the bottom of this page: https://github.com/boocs/unreal-clangd

Maybe I should make the doc links bigger. They are pretty small. Prepare to be overwhelmed with docs!

Yeah, I put the overwrite ability in a setting which changes after you've used it so there would be very little chance to overwrite. You can also just delete any clangd config files you have and it should work.

andraghetti commented 1 year ago

Hi! sorry for the late reply.

I did as you said but this is the result:

Started unreal clangd 2.0.1

Startup Intellisense check is disabled.

Warning: Couldn't set up New Source File Detection, compile commands doesn't exist yet.
Auto Parameter Hints was set to needed
Delegate Function Completions Fix was set to true
Auto Include Source Files Only was set to true
Auto Parameter Hints was set to all
Running command create Unreal/Clangd project...

Found Unreal Version: 5.2.0

*** Running command to update compile commands file... ***

No need to delete uri. It doesn't exist: /Users/Shared/Epic Games/UE_5.2/compile_commands.json
Creating compile commands file in: /Users/Shared/Epic Games/UE_5.2

*** End updating compile commands file! ***

** Error **: Unreal compile commands doesn't exists! Can't continue updating compile commands
End Task: unreal-clangd: Update Compile Commands
boocs commented 1 year ago

Check /Users/Shared/Epid Games/UE_5.2 and see if there is a compile_commands.json in there. If there is the command succeeded but the copying didn't. Also if the file is there look inside to see if it's not empty.


If there isn't then that means the command failed. You'll need to turn on debugging for this feature. Debugging requires the Microsoft C# extension. After, just change this setting to debug: 225502685-2b4df67c-182a-4686-b7d8-4a79183192c3

Run the command again and a console window should pop up with Unreal logging of the creating process.

andraghetti commented 1 year ago

The file is not generated by your script: unfortunately something fails. It could be that you need to put the path in quotes because Unreal Engine is installed in a very stupid path by default: "/Users/Shared/Epid Games/UE_5.2" has a space unfortunately.

** Error **: Unreal compile commands doesn't exists! Can't continue updating compile commands

Anyway, even if I generate it with the UnrealBuildtool with something like the following (I have a Makefile), the completionHelper.cpp is still not created and it complains.

$(UE_DOTNET) $(UE_BUILD_TOOL) -mode=GenerateProjectFiles -VSCode -project=$(PROJECT_PATH)/Project.uproject ProjectEditor $(TARGET) $(BUILD_TARGET)

Not even the .vscode/unreal-clangd/ is generated

boocs commented 1 year ago

Actually the Unreal UBT debug info should be in the Debug Console on the bottom of VSCode. The debug info is not on the window that pops up. I get a error message with the window that pops up but it still works. Even if it doesn't work you should still get the debug info on why it didn't(with the VSCode Debug Console).

You also don't have to run the create command to do this. There is a 'Update compile commands file' command that does it directly. You normally don't have to run it.

Also when you run the Update compile commands file command make sure to Skip reloading. You normally want to do this but don't do this because it'll erase the Extension debug info.

Paste that extension debug info here: (it should have something inside that looks look like this)

Creating args for compile commands creation:
type: coreclr
request: launch
program: e:\Program Files\Epic Games\UE_5.2\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool
args: [ShootUEditor,Win64,Development,e:\Users\ME\Documents\Unreal Projects\ShootU\ShootU.uproject,-Compiler=Clang,-mode=GenerateClangDataBase]
console: externalTerminal
stopAtEntry: false
cwd: e:\Program Files\Epic Games\UE_5.2
  1. You can see that UBT has a special command to create the compile_commands.json file -Compiler=Clang,-mode=GenerateClangDataBase
  2. Also make note of the first arg. My project name is ShootU but I also attach the Editor suffix to the name.
  3. My path also has a space but of course maybe Macs are different but it could be. Would like some debug info first though.

The other UBT debug info, inside VSCode's Debug Console, might be too big to post here. Maybe just find any error messages and paste them here.

boocs commented 1 year ago

Forgot to mention you can also try this setting: image

Try running Update compile commands with and without this setting to see what it does.

Change-Maker commented 1 year ago

FYI, I encountered the same error:

** Error **: Unreal compile commands doesn't exists! Can't continue updating compile commands
End Task: unreal-clangd: Update Compile Commands

But it told me that .NET core version is too old. So I upgrade my .NET core to v6.0 and it works. unreal-clangd error