YouCompleteMe (ycm),无法构建正则表达式模块

问题描述

我正在尝试为 vim 安装 ycmd 插件(在运行 git submodule update --init --recursive 之后)并且我遇到了:Failed to build regex module

在“YouCompleteMe”文件夹中运行 ./install.py 后,以下是导致所述错误的上游行:

[100%] Linking CXX shared library /home/users/jeremy/.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_core.so
[100%] Built target ycm_core
running build
running build_py
creating /home/users/jeremy/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/regex-build
creating /home/users/jeremy/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/regex-build/regex
copying regex_3/__init__.py -> /home/users/jeremy/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/regex-build/regex
copying regex_3/regex.py -> /home/users/jeremy/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/regex-build/regex
copying regex_3/_regex_core.py -> /home/users/jeremy/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/regex-build/regex
copying regex_3/test_regex.py -> /home/users/jeremy/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/regex-build/regex
running build_ext
building 'regex._regex' extension
creating /home/users/jeremy/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/regex-build/3
creating /home/users/jeremy/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/regex-build/3/temp.linux-x86_64-3.7
creating /home/users/jeremy/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/regex-build/3/temp.linux-x86_64-3.7/regex_3
gcc -pthread -B /home/users/jeremy/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/users/jeremy/anaconda3/include/python3.7m -c regex_3/_regex.c -o /home/users/jeremy/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/regex-build/3/temp.linux-x86_64-3.7/regex_3/_regex.o
gcc -pthread -B /home/users/jeremy/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/users/jeremy/anaconda3/include/python3.7m -c regex_3/_regex_unicode.c -o /home/users/jeremy/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/regex-build/3/temp.linux-x86_64-3.7/regex_3/_regex_unicode.o
gcc -pthread -shared -B /home/users/jeremy/anaconda3/compiler_compat -L/home/users/jeremy/anaconda3/lib -Wl,-rpath=/home/users/jeremy/anaconda3/lib -Wl,--no-as-needed -Wl,--sysroot=/ /home/users/jeremy/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/regex-build/3/temp.linux-x86_64-3.7/regex_3/_regex.o /home/users/jeremy/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/regex-build/3/temp.linux-x86_64-3.7/regex_3/_regex_unicode.o -o /home/users/jeremy/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/regex-build/regex/_regex.cpython-37m-x86_64-linux-gnu.so
/home/users/jeremy/anaconda3/compiler_compat/ld: /home/users/jeremy/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/regex-build/3/temp.linux-x86_64-3.7/regex_3/_regex.o: unable to initialize decompress status for section .debug_info
/home/users/jeremy/anaconda3/compiler_compat/ld: /home/users/jeremy/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/regex-build/3/temp.linux-x86_64-3.7/regex_3/_regex.o: unable to initialize decompress status for section .debug_info
/home/users/jeremy/anaconda3/compiler_compat/ld: /home/users/jeremy/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/regex-build/3/temp.linux-x86_64-3.7/regex_3/_regex.o: unable to initialize decompress status for section .debug_info
/home/users/jeremy/anaconda3/compiler_compat/ld: /home/users/jeremy/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/regex-build/3/temp.linux-x86_64-3.7/regex_3/_regex.o: unable to initialize decompress status for section .debug_info
/home/users/jeremy/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/regex-build/3/temp.linux-x86_64-3.7/regex_3/_regex.o: file not recognized: file format not recognized
collect2: error: ld returned 1 exit status
error: command 'gcc' Failed with exit status 1
Failed to build regex module.

似乎 /anaconda3/compiler_compat/ld 可执行文件与 YouCompleteMe/third_party/ycmd/third_party/regex-build/3/temp.linux-x86_64-3.7/regex_3/_regex.o 文件不兼容。>

有人知道发生了什么或我可以尝试什么吗?

解决方法

你可以用coc.nvim做代码补全,效果很好,使用起来也很方便。

几年前我曾多次尝试构建 YCM,但最终我放弃了。

,

我发现问题来自 someone hitting the same kind of issue while trying to compile PyTorch :

“整个问题在于,Anaconda 发行版带有自己的 ld 链接器,该链接器位于 /opt/anaconda/compiler_compat/ 中,它掩盖了驻留在 /usr/bin 中的系统 ld。 为了修复我的错误,我运行了 python setup.py clean 然后我临时将 Anaconda 的 ld 链接器重命名为 ld-old 以使其在 PyTorch 安装过程中不可见。从安装阶段删除 -B 选项也可以修复它。”

因此,为 ycm 编译重命名我的 anaconda ld 链接器解决了我的问题。 (我后来改名了)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...