Skip to content

C++ completion returns nothing with libclang 18 on Ubuntu 24.04 #19559

Closed

Description

@gtritchie

Describe the problem in detail

On Ubuntu 24.04 with the system libclang 18, C++ code completion in an Rcpp source file produces no completions. RStudio loads libclang and gets the file's compile arguments, but libclang fails to parse the translation unit, so get_cpp_completions returns null and no popup appears.

Seen in CI for #19549 (linux-server and linux-desktop e2e jobs, Ubuntu 24.04 runners, R 4.6.1). .rs.isClangAvailable() reports:

/usr/lib/llvm-18/lib/libclang.so.1
   LOADED: 18.1.3
[1] TRUE

After typing s., the get_cpp_completions request returns {"result":null} within about 10 ms, and the session logs, once per request:

ERROR Error parsing translation unit /tmp/workdir_1d173c16071b/completion_aria_1794342138683.cpp; LOGGED FROM: rstudio::core::libclang::TranslationUnit rstudio::core::libclang::SourceIndex::getTranslationUnit(const std::string&, bool) src/cpp/core/libclang/SourceIndex.cpp:333

The same file completes as expected on macOS, both locally with the Command Line Tools libclang 21.0.0 and on the macOS CI runners. I haven't reproduced it on a Linux machine outside CI, and the cause of the parse failure isn't known yet.

Steps to reproduce

  1. On Ubuntu 24.04, install libclang-18 (so /usr/lib/llvm-18/lib/libclang.so.1 exists) and the Rcpp package.

  2. Create and save probe.cpp:

    #include <Rcpp.h>
    #include <string>
    // [[Rcpp::export]]
    int probe() {
      std::string s;
    
      return 0;
    }
  3. Open it in RStudio, put the cursor on the blank line inside probe(), and type s..

Describe the behavior you expected

A completion popup lists the members of std::string.

Metadata

Metadata

Assignees

Labels

autocompletionbug

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions