Nik Kantar

Tuesday, March 15, 2016

YouCompleteMe Compilation with Little RAM Solvable with Swap

I ran into a compilation issue on my small DigitalOcean droplet and solved it with some good ol' swap.

I switched to Vim a few weeks ago (Neovim, to be precise), and have been wanting to set it up the same way on all the environments I use. My work and personal Macs were easy enough, but I ran into a YouCompleteMe compilation issue on my tiny DigitalOcean droplet. A little bit of searching suggested it may be due to low RAM, so I added some swap and everything worked fine. At the end I got rid of said swap, since DO suggests avoiding it and I have no specific need for it.

This solution should more/less work on other environments with low RAM as well — virtual servers on other hosts, local VMs, Raspberry Pis, old machines, etc. Obviously, it'll only work if low RAM is the cause, which seems to be a reasonably common situation according to the Interwebs.

For both posterity and my own inevitable reference in the future, I'm reproducing the steps here:

# in the middle of following YouCompleteMe installation instructions
# (in ~/.config/nvim/bundle/YouCompleteMe
$ ./install.py
# [stuff happens]
make: *** [ycm_core] Error 2

# alright, let's give ourselves a gig for the swapfile
$ sudo fallocate -l 1G /swapfile

# restrict permissions to root-only just in case
$ sudo chmod 600 /swapfile

# actually make the swapfile swap
$ sudo mkswap /swapfile

# enable swap
$ sudo swapon /swapfile

# run the YCM installer again
$ ./install.py
# [all goes well this time]

# cool, let's disable swap
$ sudo swapoff -a

# and remove the swapfile
$ sudo rm /swapfile

Happy autocompleting!


Tags: vim

Thanks for reading! You can keep up with my writing via the feed or newsletter, or you can get in touch via email or Mastodon.


Older:
Goals for 2016
Newer:
Instagram to Abandon Chronological Feed