Holochain Forum

YouCompleteMe code completion engine does not work when started from holonix-shell

One issue I have with nix-shell is, that the YouCompleteMe code completion engine does not work in vim when started from a nix-shell.

Reproduce:

  • install arch
  • install vim
  • install vim-youcompleteme-git from AUR
  • install nix
  • setup holonix
  • holonixify a repo
  • start nix-shell
  • hc package … works fine
  • open some rust file with vim … ycm doesn’t work

desired behavior:
ycm works in vim

observed behavior:
ycm server fails to start, error log:

Traceback (most recent call last):
  File "/nix/store/v5ifc15l78lmdlw8imhixch81dd5cclz-python3-3.7.5/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/nix/store/v5ifc15l78lmdlw8imhixch81dd5cclz-python3-3.7.5/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/share/vim/vimfiles/python/ycm/../../third_party/ycmd/ycmd/__main__.py", line 199, in <module>
    Main()
  File "/usr/share/vim/vimfiles/python/ycm/../../third_party/ycmd/ycmd/__main__.py", line 166, in Main
    code = ImportAndCheckCore()
  File "/usr/share/vim/vimfiles/third_party/ycmd/ycmd/utils.py", line 638, in ImportAndCheckCore
    LoadYcmCoreDependencies()
  File "/usr/share/vim/vimfiles/third_party/ycmd/ycmd/utils.py", line 623, in LoadYcmCoreDependencies
    ctypes.cdll.LoadLibrary( libclang_path )
  File "/nix/store/v5ifc15l78lmdlw8imhixch81dd5cclz-python3-3.7.5/lib/python3.7/ctypes/__init__.py", line 442, in LoadLibrary
    return self._dlltype(name)
  File "/nix/store/v5ifc15l78lmdlw8imhixch81dd5cclz-python3-3.7.5/lib/python3.7/ctypes/__init__.py", line 364, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libclangAST.so.9: cannot open shared object file: No such file or directory

libclangAST.so.9 does exist on my system:
/usr/lib/libclangAST.so.9

Usually ycm and vim work fine on my system.

Any ideas, how can I get ycm working when running vim from a holochain.love nix-shell?

The problem is probably, that ycm is built against clang version 9 while in the nix-shell clang is in version 7.

Adding nix packages vim and vimPlugins.youcompleteme to the nix derivation could be a solution. However, when I tried it out, my arch vim is replaced with the nix vim, but the vimPlugins.youcompleteme has no effect (nor with neovim).
( Add packages as instructed in section “How to extend holonix” on this page https://docs.holochain.love/docs/configure/ )

For now, when developing hApps, I’ll just rustup the corresponding rust version on my arch system and open code with vim not from the nix-shell.
I guess, this is also how things work for people using other IDEs with code completion: Having a separate rustc / rls / rust-analysis / rust-src on their OS for development and using nix-shell only for packaging and running.

1 Like

Thanks very much @fairlix for following up with your solution. Would you be willing to post a short howto in #learning-library:recipes-howtos ?