You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Linux环境下编译VS Code遇x11/xkbfile依赖检测失败求助

Fixing "x11/xkbfile not found in pkg-config" When Compiling VS Code with Yarn on Linux

I’ve run into this exact issue before when building VS Code across different Linux distros, so let’s walk through targeted fixes based on your operating system:

First, Verify the Problem Source

First, confirm if pkg-config can actually locate the installed .pc files by running:

pkg-config --list-all | grep -E "(x11|xkbfile)"

If you get no output, the issue is definitely that your PKG_CONFIG_PATH isn’t pointing to the directory where these files live.

Fix for Ubuntu 18.04

On Ubuntu 18.04, the .pc files for libx11-dev and libxkbfile-dev are almost always in /usr/lib/x86_64-linux-gnu/pkgconfig/.

  1. Temporarily set the path to test if it works:
    export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig/:$PKG_CONFIG_PATH
    
  2. Try running yarn again in your VS Code repo. If it succeeds, make the change permanent by adding the export to your user’s shell config (better than modifying /etc/profile for system-wide changes):
    echo 'export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig/:$PKG_CONFIG_PATH' >> ~/.bashrc
    source ~/.bashrc
    

Fix for CentOS 7/8

CentOS stores 64-bit .pc files in /usr/lib64/pkgconfig/ instead.

  1. Temporarily apply the path:
    export PKG_CONFIG_PATH=/usr/lib64/pkgconfig/:$PKG_CONFIG_PATH
    
  2. Test yarn again. If it works, save the setting permanently:
    echo 'export PKG_CONFIG_PATH=/usr/lib64/pkgconfig/:$PKG_CONFIG_PATH' >> ~/.bashrc
    source ~/.bashrc
    

If the Above Doesn’t Work

If pkg-config still can’t find the files, manually locate them first:

find /usr -name "x11.pc"
find /usr -name "xkbfile.pc"

Take the directory path from the results (e.g., /usr/local/lib/pkgconfig/ if you installed from source) and add it to PKG_CONFIG_PATH instead.

Also, avoid running yarn with sudo unless absolutely necessary—sudo doesn’t inherit your user’s environment variables by default. If you must use sudo, use sudo -E yarn to preserve your PKG_CONFIG_PATH setting.

内容的提问来源于stack exchange,提问作者AGreenHand

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 20:52:42