vscode-cpptools
vscode-cpptools copied to clipboard
IntelliSense does not work if folder opened through a symbolic link
This is derived from: https://github.com/microsoft/vscode-cpptools/issues/4569
Repro:
- On Linux, create a local directory. (i.e. 'mkdir actual')
- Create a source file (test.cpp) in that directory, with the following contents:
#if 0
int i;
#else
int j;
#endif
this should squiggle
- Create a symbolic link to that local directory. (i.e. 'ln -s actual softlink')
- Open the 'softlink' folder into VS Code.
Seeing: inactive regions are not dimmed. Squiggles are not applied.
Log output indicates that IntelliSense processing was successful against the file in the actual path, but the results are not applied. There are likely some comparisons of actual and softlink paths that are failing.
We're using realpath() to canonicalize paths on Linux and Mac, whereas on Win32 we don't try to resolve symbolic links at all. We may want to avoid using realpath(), and find an equivalent way to canonicalize paths that doesn't resolve symbolic links.
Just banged my head against a wall for a few hours trying to replicate my setup from my Linux laptop to my WSL desktop. Had the repo I was working on living in my Windows user folder with a symlink to it in my WSL home directory. Cloning my repo directly to my WSL home directory resolved the issue.
Commenting for visibility since it took a while to figure out what was going on with my syntax highlighting
At least a warning should be shown when this scenario happens. It took me some time to track this issue back to this bug report.
@surban Agreed. See https://github.com/microsoft/vscode-cpptools/issues/9498
I spent almost 10 hours trying to track down why Highlighting would not work correctly. I was using a link on the Linux desktop to access my projects folders. Highlighting was broken when using that link but if I navigated directly to the Folder and Right click open VSCode everything worked fine. My current workaround has been to use "Create a new launcher here" set the command to Nemo /Home/User/Myprojects This opens up the folder and allows me to right click open with VScode and everything work correctly.
Same issue as everyone above. Took me also a bunch of hours. Playing with config files... until I figured out that the problem was due to a symlink. It was ChatGPT "who" pointed me in the right direction.
IMO
- the folder/workspace config should keep the path given by the user (the one that includes a symlink)
- but as soon as the Folder is clicked, a 'realpath' should be done immediately and only that real path should be used during the session (passed to interllisense/C++ compiler etc.).
Related on Stack Overflow: VS Code Error Squiggles do not work if the project dir is a symlink.
I have same issue as well, the semantic highlighting doesn't work on files which are in a path having symbolic. It also took me 5+ hours to locate the issue.
Yet another user running into this issue with semantic highlighting through symbolic links. The team I'm working on uses workspaces with a lot of symbolic links, so it would be really nice to see this fixed so I don't have to always add the files from their true path manually.
I am having the same issue as everyone else. Are there any workarounds?
It should be noted that this is also an issue if you have symlinks in your include directory including the system include directory. The issue in my case was that /usr/include/pybind11
was a symlink to the system-packages
folder of the system python distro. Any time I tried to include something from pybind11
I would get lots of red and orange squiggles.
Any progress on this ?
@YonatanNachum Not specifically.
Recently Dropbox on Mac changed to use the "file provider", which puts the Dropbox folder in a symlinked path, so this breaks for any Mac VS Code user who stores files on Dropbox. (Workaround is to open VS Code folders through ~/Library/CloudStorage/Dropbox instead of the provided Dropbox link).
There is another aspect of this that I haven't seen anyone comment about: F2 rename doesn't work. From within VSCode I opened a workspace "remotely" hosted in a WSL2 instance. That directory tree was symlinked to a github directory on my Windows host via /mnt/d/... Trying to refactor/rename a structure shared across multiple files failed, and the error given was "Unable to process IntelliSense for file with same canonicalized path as existing file."
Trying to refactor/rename a structure shared across multiple files failed, and the error given was "Unable to process IntelliSense for file with same canonicalized path as existing file."
Same issue. Moreover, the file will be "reopened" (using the real path) next to the active editor, and the newly opened editor is marked "changed" with the very identifier renamed to what I want.
Updated: For those who don't compromise with using real paths, a workaround is to use a bind mount.
@sean-mcmanus I feel that many developers would appreciate it if this bug was fixed. Being able to clone your repos into Dropbox and then symbolically link your projects to your workspace (for example) is a safe and efficient way of backing up your work without having to commit and push in-progress work that breaks the build. This has proven very useful in research, where this workflow makes prototyping much easier having access to Dropbox's version control.