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
YouCompleteMeby adding it to the list of plugins in yourvimrcfile, and then running the:PlugInstallcommand in vim.Plug 'ycm-core/YouCompleteMe':PlugInstall -
Apply the provided patch1 to use
ghc::filesysteminstead ofstd::filesysteminycmd.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
df3d7ebin theYouCompleteMerepository (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.txtto downloadghc::filesystemheader to the build directory, replaces all#include <filesystem>with#include <ghc_filesystem.hpp>, and changes all references tostd::filesystemto useghc::filesysteminstead. -
^ If you are on a device with limited RAM, try using
export YCM_CORES=1before runninginstall.py. This controls the number of compilation jobs executed in parallel (a.k.a.-j), and overrides the defaultmultiprocessing.cpu_count().

