vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

IntelliSense does not work if folder opened through a symbolic link

Open Colengms opened this issue 5 years ago • 18 comments

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.

Colengms avatar Nov 08 '19 18:11 Colengms

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

owaink avatar May 05 '22 05:05 owaink

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 avatar Sep 07 '22 08:09 surban

@surban Agreed. See https://github.com/microsoft/vscode-cpptools/issues/9498

sean-mcmanus avatar Sep 07 '22 19:09 sean-mcmanus

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.

Uvamosk avatar Feb 16 '23 00:02 Uvamosk

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.).

BecauseTheWorldIsRound avatar Mar 30 '23 08:03 BecauseTheWorldIsRound

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.

xianpul avatar Jun 07 '23 10:06 xianpul

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.

ericjessee avatar Jun 26 '23 21:06 ericjessee

I am having the same issue as everyone else. Are there any workarounds?

Daigoro96 avatar Oct 23 '23 08:10 Daigoro96

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.

richbai90 avatar Nov 15 '23 21:11 richbai90

Any progress on this ?

YonatanNachum avatar Apr 05 '24 08:04 YonatanNachum

@YonatanNachum Not specifically.

sean-mcmanus avatar Apr 05 '24 18:04 sean-mcmanus

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).

wjquigs11 avatar May 08 '24 14:05 wjquigs11

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."

kt-bouse avatar May 14 '24 22:05 kt-bouse

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.

lewis-yeung avatar Jun 17 '24 13:06 lewis-yeung

@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.

adthoms avatar Jun 20 '24 04:06 adthoms