Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cquery Error: Could not normalize path xxx #47

Open
zhuzhongshu opened this issue Jul 9, 2018 · 3 comments
Open

Cquery Error: Could not normalize path xxx #47

zhuzhongshu opened this issue Jul 9, 2018 · 3 comments

Comments

@zhuzhongshu
Copy link

When I turn on the cquery mode, it will print huge amount of errors in lsp std error buffer, such as :

(   0.704s) [     FDAB2700]  file_consumer.cc:67    | Could not normalize path /bin/../lib64/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../include/c++/8.1.1/bits/stringfwd.h
(   0.704s) [     FDAB2700]  file_consumer.cc:67    | Could not normalize path /bin/../lib64/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../include/c++/8.1.1/bits/stringfwd.h
(   0.704s) [     FDAB2700]  file_consumer.cc:67    | Could not normalize path /bin/../lib64/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../include/c++/8.1.1/bits/memoryfwd.h
(   0.704s) [     FDAB2700]  file_consumer.cc:67    | Could not normalize path /bin/../lib64/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../include/c++/8.1.1/iosfwd
(   0.704s) [     FDAB2700]  file_consumer.cc:67    | Could not normalize path /bin/../lib64/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../include/c++/8.1.1/bits/postypes.h
(   0.704s) [     FDAB2700]  file_consumer.cc:67    | Could not normalize path /bin/../lib64/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../include/c++/8.1.1/cwchar
(   0.704s) [     FDAB2700]  file_consumer.cc:67    | Could not normalize path /bin/../lib64/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../include/c++/8.1.1/cwchar
(   0.704s) [     FDAB2700]  file_consumer.cc:67    | Could not normalize path /bin/../lib64/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../include/c++/8.1.1/iomanip
(   0.704s) [     FDAB2700]  file_consumer.cc:67    | Could not normalize path /bin/../lib64/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../include/c++/8.1.1/bits/ios_base.h
(   0.704s) [     FDAB2700]  file_consumer.cc:67    | Could not normalize path /bin/../lib64/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../include/c++/8.1.1/ext/atomicity.h
(   0.704s) [     FDAB2700]  file_consumer.cc:67    | Could not normalize path 
@Silentd00m
Copy link

Silentd00m commented Aug 17, 2018

I can confirm this behaviour under manjaro/arch linux.

Minimal code to trigger it:

test.cpp

#include <iostream>

int main()
{
}

CMakeLists.txt

cmake_minimum_required(VERSION 2.8.4)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

add_executable(run test.cpp)

GCC: 8.1.1 20180531

@lebyzhao
Copy link

lebyzhao commented Nov 5, 2018

I got the same error, but sometimes it works.

@rpav
Copy link

rpav commented Nov 16, 2018

I have this issue as well. This seems to be an issue with NormalizePath and RelPathNotExpandSymlink in platform_posix.cc. It seems this makes naive assumptions about paths, e.g.,

/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../..
  .. is the same as ..
/

One might assume counting up for and down for .. produces the correct path, and that's what the code seems to do:

    } else if (next_token == "..") {
      // Strip the last path component except when it is single "/"
      if (resolved.size() > 1)
        resolved.resize(resolved.rfind('/', resolved.size() - 2) + 1);
      continue;

However that's not the actual resolution of this path:

$ realpath /bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../..
/usr

And indeed, replacing the call with a call to the "real" realpath(3) (yes it's broken/insecure/etc) fixes this issue for me.

Probably, this needs to find the canonical path of .. whenever it encounters one.

edit: i keep typing relpath 😕

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants