Francesco Borzi
Francesco Borzi

Reputation: 61854

Visual Studio Code: Unable to open 'MyFile.h': File not found

I got this kind of errors when attempting to go to the declaration of some attributes/methods (using ctrl/cmd + left click):

Unable to open 'MyFile.h': File not found

probably this happens because the file MyFile.h has been moved recently.

Upvotes: 11

Views: 12576

Answers (3)

Seblor
Seblor

Reputation: 7136

I had the same behavior when browsing the file changes in the source control panel but for me the issue was that while I was reworking my project architecture, I had a remaining .gitmodules file in the root of my project, but the subdirectory was not a repository itself.

So I just deleted the .gitmodules file and it worked again.

Upvotes: 3

Sharon A
Sharon A

Reputation: 2627

I had the same issue and solved it by reloading my VS code window.

Ctrl + Shift + P on Windows

Command + Shift + P on Mac

Type:

Reload Window

Then select Developer: Reload Window

Upvotes: 9

Francesco Borzi
Francesco Borzi

Reputation: 61854

I solved this problem by forcing VSCode to re-scan the project structure.

In order to do that, I closed VSCode, deleted the .vscode hidden folder of my project, and opened it again.

Upvotes: 9

Related Questions