Open zhuzhongshu opened 6 years ago
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
I got the same error, but sometimes it works.
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
:confused:
When I turn on the cquery mode, it will print huge amount of errors in
lsp std error
buffer, such as :