-
Notifications
You must be signed in to change notification settings - Fork 162
Windows paths are not always properly normalized #543
Comments
We should change this message to be more clear, ie, 'File <foo.cc> is not indexed'. Are you blacklisting certain files from being indexed? A header file is only indexed if a cc file in the project which is indexed includes it. |
I don't even know how I would blacklist a file from being indexed. The message appears for cc/cpp files, which are explicitly listed in compile_commands.json. |
Another interesting observation: Things break only after I open the affected files in VS Code. When cquery starts indexing and I don't yet have the files open, I see the correct warning for the files, which means that the files can be analyzed correctly (and all headers are found). Only once I open the file in the editor, something breaks and the file becomes red all over because of header files which cannot be found. |
Can you reproduce on a small sample project that I can try locally? |
Probably not, but I have some more information, which hopefully helps you to find the root cause: As I said, the cache file that's working is in I analyzed the difference between these two
Further analyzing the {
"directory": "C:\\Develop\\git\\out",
"command": "cl.exe ... some other args ... -c -Fosource_file.obj C:/Develop/git/src/source_file.cpp",
"file": "C:/Develop/git/src/source_file.cpp"
} What's in the "good" cache file: [
"cl.exe",
"-working-directory=C:\\Develop\\git\\out",
... some other args ...
"-FC:/Develop/git/out/osource_file.obj",
"C:/Develop/git/src/source_file.cpp",
"-resource-dir=C:/Develop/cquery/build/release/lib/LLVM-6.0.0-win64/lib/clang/6.0.0",
"-Wno-unknown-warning-option",
"-fparse-all-comments"
] What's in the bad cache file: [
"cl.exe",
"-working-directory=C:\\Develop\\git\\out",
"-fms-extensions",
"-fms-compatibility",
"-fdelayed-template-parsing",
... some other args taken from a different TU `other_source_file.cpp` from the same compile_commands.json ...
"-FC:/Develop/git/out/oother_source_file.obj",
"c:/Develop/git/src/source_file.cpp",
"-resource-dir=C:/Develop/cquery/build/release/lib/LLVM-6.0.0-win64/lib/clang/6.0.0",
"-Wno-unknown-warning-option",
"-fparse-all-comments"
] There are at least two problems here:
|
Saw the same thing, I changed the case of C: in the compile_commands.json file to c: and it got further. Doesn't look like the lookup is taking case insensitivity on Windows (and to some degree on Mac) into account. But haven't dug further into it yet. |
Indeed, when I change the case in compile_commands.json, it seems to work. |
I'm a bit surprised changing the case fixes this, but it sounds like we're missing normalization somewhere. Maybe project.cc is not normalizing. |
There have been a bunch of normalization changes. Please reopen if this is still an issue. |
I just pulled from master, and the issue perists: I'm still getting messages like Postprocessing I'm also getting warnings |
Okay, I was finally able to build an minimal example to reproduce this (it's slightly extended from the one for #594): The point is that "doesn't work" means that I get |
message_handler.cc:~65 does use a "NormalizedPath", which just doesn't normalize at all, consequently failing for files with "incorrect" casing... VScode seems to supply lower case drive letters to the language server when opening/switching focus to source files |
The most robust fix is most likely to update paths on output to match what we received on input, even if internally we are storing something else. |
I had the impression that this normalization mainly serves the purpose for efficient lookup in the file<->index lookups? |
Yep, that's right. But we get paths from different sources (libclang, compile_commands.json, editor) which may spell the file differently (ie, casing, |
Would that be problematic to do reactively with a reverse lookup because cquery has to supply paths it didn't yet hear from the client? I remember that there were times with the ms tools where I looked up a definition and it would show them in a different tab than the already opened, just that the paths were displayed differently. I wonder if it's really the language server who should handle this, or if that's a problem only the client can truly solve. |
This is an issue in the client cquery is working around. Typically cquery has been willing to work around external bugs to provide a better end-user experience.
Sorry, I'm having trouble parsing this. But for paths we haven't seen yet from the client, we will supply what the OS realpath is (hoping that matches with the client). |
You seem to have parsed it just like I meant it to be parsed ;) You probably know it, but maybe there is a way to query certain clients for how they represent paths to files within the opened folders, and then do a client-specific normalization on the path server->client? |
The only broken client I'm aware of is vscode; it should be feasible to do this client-side. |
(if it ends up that only vscode is affected by this, I'm good with handling it client-side) |
That sounds reasonable. Are the vscode people aware of this? |
There is microsoft/vscode#12448, which might be related |
Okay, the driver letter needs to be normalized by hand - in my experimental build I do this in a not so robust way, but it does the trick, I've had no cquery-side errors anymore. If no one else overtakes me, I'll see that better normalization is part of the unqlite pr... As to the vscode side, I don't really know much about ts/js to be of any help there. But paths really need to be prepared for vscode to consume as well. Since the issue is open for ages, I don't count on them doing anything about it anytime soon.... |
Please give this a try again on the latest master. It should be fixed by b728cc0. Reopen if not. Thanks! |
I have tried the latest master, and now there's a somewhat different problem: When I use "go to definition" on something which is defined in different file, the file that's opened is I admit that this should be fixed in VS Code and I'm not sure if cquery can improve the situation ... |
I've pushed a commit that should help with that; let me know if there are still issues. |
The problem persists in master. It also materializes in another way: The Problems view in VS Code shows warnings for files that are not opened (I don't know if that's intended, but I actually like it), but the paths of those files also have the wrong casing: They are shown as Furthermore, when I look at the cquery output inside VS Code ("Output" panel), I can see |
Can you give it another try? |
I don't notice any change ... the problem persists. Actually, the behavior before the paths were normalized to all-lowercase was better, because the problems with VS Code didn't occur. There was only the problem that I needed to preprocess |
Yea, unfortunately I'm not sure what else I can do on cquery's side. |
I'm having a problem where cquery is not able to find certain header files, and I'm suspecting that the reason has something to do with paths in Windows (maybe case-insensitivity?).
I found that all the files where it does not work have their cache files in
c@@Develop@git@src
with relative file paths within, while those that work have their cache files in@c@@Develop@git@src
with absolute file paths (such asC@@Develop@git@src@some_file.cpp
) within.And I'm getting messages of the form:
... although
c:/Develop/git/src/some_file.cpp
exists.The text was updated successfully, but these errors were encountered: