Visual Studio 2022 - WSL-GCC-Debug - cannot open file (Ubuntu 24.04 c++ include) - E1696

JR 0 Reputation points
2024-08-25T00:44:19.0133333+00:00

Hello,

I am attempting to setup a cross-platform environment with Visual Studio 2022, using WSL Ubuntu-24.04, and WSL-GCC-Debug configuration.

VS2022 intellisense is erroring with E1696, "cannot open source file" for the headers in my WSL distro.

User's imageUser's image


Similar questions suggest to run Project -> Rescan Solution. So, I ran it, and the logs below indicate that the includes are downloaded from the WSL distro into my Windows.

liblinux.Local.Shell.WindowsSubsystemShell: Read async: 46903da0-8c99-4008-8256-a9a9188696d6

liblinux.Shell.AsyncCommandBase: Command "rm -rf $HOME/.vs/rsync/16688_0ae58fd9-be41-475f-bc0e-e19771ad3b59/" finished with exit code 0 after 1.55ms

	liblinux.IO.Rsync: Transfer of source='/usr/lib/gcc/x86_64-linux-gnu/14/include, /usr/local/include, /usr/include/x86_64-linux-gnu, /usr/include, /usr/include/c++/14, /usr/include/x86_64-linux-gnu/c++/14, /usr/include/c++/14/backward' dest='C:\Users\Joel\AppData\Local\Microsoft\Linux\HeaderCache\1.0\Ubuntu-24.04\usr\lib\gcc\x86_64-linux-gnu\14\include, C:\Users\Joel\AppData\Local\Microsoft\Linux\HeaderCache\1.0\Ubuntu-24.04\usr\local\include, C:\Users\Joel\AppData\Local\Microsoft\Linux\HeaderCache\1.0\Ubuntu-24.04\usr\include\x86_64-linux-gnu, C:\Users\Joel\AppData\Local\Microsoft\Linux\HeaderCache\1.0\Ubuntu-24.04\usr\include, C:\Users\Joel\AppData\Local\Microsoft\Linux\HeaderCache\1.0\Ubuntu-24.04\usr\include\c++\14, C:\Users\Joel\AppData\Local\Microsoft\Linux\HeaderCache\1.0\Ubuntu-24.04\usr\include\x86_64-linux-gnu\c++\14, C:\Users\Joel\AppData\Local\Microsoft\Linux\HeaderCache\1.0\Ubuntu-24.04\usr\include\c++\14\backward' lasted for: 4633ms

    liblinux.Services.RsyncRemoteCompilerIOImpl: Copying headers lasted 4640ms

Microsoft.VisualStudio.Linux.LinuxHeadersUpdateTaskBare: CreateVisualStudioNotificationsTask updateHeaders.LogMessage(e.Message)=Done syncing header files.

    liblinux.Services.HeaderCacheManager: Updated headers: C:\Users\Joel\AppData\Local\Microsoft\Linux\HeaderCache\1.0\Ubuntu-24.04\usr\lib\gcc\x86_64-linux-gnu\14\include;C:\Users\Joel\AppData\Local\Microsoft\Linux\HeaderCache\1.0\Ubuntu-24.04\usr\local\include;C:\Users\Joel\AppData\Local\Microsoft\Linux\HeaderCache\1.0\Ubuntu-24.04\usr\include\x86_64-linux-gnu;C:\Users\Joel\AppData\Local\Microsoft\Linux\HeaderCache\1.0\Ubuntu-24.04\usr\include;C:\Users\Joel\AppData\Local\Microsoft\Linux\HeaderCache\1.0\Ubuntu-24.04\usr\include\c++\14;C:\Users\Joel\AppData\Local\Microsoft\Linux\HeaderCache\1.0\Ubuntu-24.04\usr\include\x86_64-linux-gnu\c++\14;C:\Users\Joel\AppData\Local\Microsoft\Linux\HeaderCache\1.0\Ubuntu-24.04\usr\include\c++\14\backward

Microsoft.VisualStudio.Linux.LinuxHeadersUpdateTaskBare: CreateVisualStudioNotificationsTask updateHeaders.LogMessage(e.Message)=Local copy of remote sysroot done.

Microsoft.VisualStudio.Linux.LinuxHeadersUpdateTaskBare: CreateVisualStudioNotificationsTask updateHeaders.LogMessage(e.Message)=Writing information cache to disk.

Microsoft.VisualStudio.Linux.LinuxHeadersUpdateTaskBare: CreateVisualStudioNotificationsTask CreateLocalSysroot - done
Microsoft.VisualStudio.Linux.LinuxHeadersUpdateTaskBare: UpdateHeadersFinished Finished updating headers from 'Ubuntu-24.04'.



I navigated to the folders and do indeed see the WSL header files for the standard library. The image below shows the standard library header files pulled from the WSL distro Ubuntu 24.04.

User's image


VS2022 must have a configuration for the HeaderCacheManager where it stores these folder paths. Something is affecting it to not allow intellisense to find the headers. I do have both gcc/g++ versions 13 and 14 installed, perhaps VS2022 cannot distinguish between the two?

Any help would be appreciated.

Thanks,

Joel

Developer technologies Visual Studio Debugging
Developer technologies Visual Studio Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Tianyu Sun-MSFT 34,436 Reputation points Microsoft External Staff
    2024-08-26T08:00:39.47+00:00

    Hello @JR,

    Thank you for taking time to post this issue in Microsoft Q&A forum.

    Looks like this is a known issue and has been fixed in a future release version of VS.

    See this thread: IntelliSense can not find source file on WSL-GCC Cmake configuration. That thread was duplicated to this thread: VisualStudio intellisense not working after update for cmake project which is Fixed – Pending Release.

    Can you confirm that the issue you got is the same to the issue mentioned in above two threads?

    If so, I may suggest you kindly wait and update to a newer version of Visual Studio 2022(you can follow above threads for any latest information).

    Feel free to let us know if you have any further concerns :)

    Thanks for your understanding.

    Sincerely,

    Tianyu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.