#999486 vim-youcompleteme: depends on clangd and python3-distutils

#999486#5
Date:
2021-11-11 19:56:40 UTC
From:
To:
Dear Maintainer,

Upon a fresh install of vim-youcompleteme on an otherwise almost empty
system (a live system, in fact), I noticed that two particular
packages were mandatory to get it to work (for C++ completion at least)

 - clangd

 - python3-distutils

In particular, when the latter is absent, :YcmDebugInfo points to an
stderr file that says:

     2021-11-11 11:35:02,283 - ERROR - Error occurred while loading global extra conf
     /usr/lib/ycmd/ycm_extra_conf.py
    Traceback (most recent call last):
      File "/usr/lib/ycmd/ycmd/extra_conf_store.py", line 92, in _CallGlobalExtraConfMethod
        module = Load( global_ycm_extra_conf, force = True )
      File "/usr/lib/ycmd/ycmd/extra_conf_store.py", line 171, in Load
        module = LoadPythonSource( _RandomName(), module_file )
      File "/usr/lib/ycmd/ycmd/utils.py", line 373, in LoadPythonSource
        return importlib.machinery.SourceFileLoader( name, pathname ).load_module()
      File "<frozen importlib._bootstrap_external>", line 469, in _check_name_wrapper
      File "<frozen importlib._bootstrap_external>", line 969, in load_module
      File "<frozen importlib._bootstrap_external>", line 794, in load_module
      File "<frozen importlib._bootstrap>", line 274, in _load_module_shim
      File "<frozen importlib._bootstrap>", line 711, in _load
      File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 790, in exec_module
      File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
      File "/usr/lib/ycmd/ycm_extra_conf.py", line 31, in <module>
        from distutils.sysconfig import get_python_inc
    ModuleNotFoundError: No module named 'distutils.sysconfig'

If python3-distutils is installed but not clangd, that same stderr file
complains as:

    2021-11-11 11:50:49,299 - ERROR - No Clangd executable found at /usr/bin/clangd
    2021-11-11 11:50:49,299 - INFO - Completion config: 50, detailing -1 candiates
    2021-11-11 11:50:50,985 - INFO - Received filetype completion available request
    2021-11-11 11:50:52,271 - INFO - Received debug info request


Adding these two packages was enough to satisfy my needs.

I don't know if Ycm has a set of more basic functionalities that would
justify not having the packages above as dependencies.

Best regards,

E.

#999486#10
Date:
2022-06-10 16:20:18 UTC
From:
To:
Hi,

sorry for the late reply.

(fsvo) Thankfully, this is a misunderstanding based on a bug. The
dependency on python3-distutils was caused by a buggy patch for
the file /usr/lib/ycmd/ycm_extra_conf.py shipped in ycmd and used
by vim-youcompleteme: The patch was removing the line using that
package, but not the import… (#990466) … doh!

clangd is the preferred completer for the C family, but YCM falls back to
another completer based on libclang if not available/usable. You could
force that fallback (and avoid the message) with
`let g:ycm_use_clangd = 0` in your vimrc if you so choose.

Both completers require a functioning ycm_extra_conf.py through.
The C family of languages in particular tend to need some hand-holding
so the completers can find the right flags to use either with
a compilation database (compile_commands.json) for the project at hand
generated by e.g. CMake on request (-DCMAKE_EXPORT_COMPILE_COMMANDS=ON)
or with a likely project-specific handcrafted `.ycm_extra_conf.py' file.

The global ycm_extra_conf.py tries to be a reasonably generic example
that can with some luck work on simple projects, but mildly more complex
ones tend to require additional defines and flags that can't be guessed.


You will find more information on the various completers in the ycmd
package, start here: /usr/share/doc/ycmd/README.Debian.gz


I hope that clarifies things, if not feel free to ask – and I hopefully
reply a little faster next time… – while I take the liberty now to close
this bug report as the ycmd bug bringing this on is hopefully fixed now
with my upload yesterday.


Best regards

David Kalnischkies