As of March 2021, YouCompleteMe compiles fine on Termux, but it crashes once the plugin is loaded. The following error can be noticed in the logs:
ImportError: dlopen failed: cannot locate symbol "_ZNSt6__ndk14__fs10filesystem18__weakly_canonicalERKNS1_4pathEPNS_10error_codeE" referenced by "/data/data/com.termux/files/home/.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_core.so"...
The problem is caused by the lack of support for std::filesystem
on ndk prior to r22. While there is an ongoing PR that aims to upgrade Termux to use ndk r22, the instructions below can be used to run YouCompleteMe on Termux before the linked PR gets merged.
-
Install the prerequisite Termux packages.
pkg install vim-python git python clang cmake
-
Install vim-plug by following the official instructions.
-
Install
YouCompleteMe
by adding it to the list of plugins in yourvimrc
file, and then running the:PlugInstall
command in vim.Plug 'ycm-core/YouCompleteMe'
:PlugInstall
-
Apply the provided patch1 to use
ghc::filesystem
instead ofstd::filesystem
inycmd
.cd ~/.vim/plugged/YouCompleteMe/third_party/ycmd curl https://gist.githubusercontent.com/AjmalShajahan/dacfc482ba38b93a389653f675049d08/raw/ycmd_filesystem_patch.patch | git apply --3way -
-
Build and install YouCompleteMe2.
cd ~/.vim/plugged/YouCompleteMe ./install.py
-
^ The patch has been written for commit
df3d7eb
in theYouCompleteMe
repository (the master branch at the time of this writing). If you are from the future, and the patch no longer applies, you might have to manually resolve the merge conflict. The patch simply modifiesCMakeLists.txt
to downloadghc::filesystem
header to the build directory, replaces all#include <filesystem>
with#include <ghc_filesystem.hpp>
, and changes all references tostd::filesystem
to useghc::filesystem
instead. -
^ If you are on a device with limited RAM, try using
export YCM_CORES=1
before runninginstall.py
. This controls the number of compilation jobs executed in parallel (a.k.a.-j
), and overrides the defaultmultiprocessing.cpu_count()
.