alacritty: Building with cargo fails, unable to run custom build command for `servo-fontconfig-sys`

System OS: Ubuntu Version: 20.04 LTS

Logs cargo build --release

   Compiling servo-fontconfig-sys v5.1.0
error: failed to run custom build command for `servo-fontconfig-sys v5.1.0`

Caused by:
  process didn't exit successfully: `/home/user/Documents/alacritty/target/release/build/servo-fontconfig-sys-3a4fc4cb44fe63f6/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=FONTCONFIG_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=FONTCONFIG_STATIC
  cargo:rerun-if-env-changed=FONTCONFIG_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr
  thread 'main' panicked at '`"pkg-config" "--libs" "--cflags" "fontconfig" "fontconfig >= 2.11.1"` did not exit successfully: exit status: 1
  --- stderr
  Package fontconfig was not found in the pkg-config search path.
  Perhaps you should add the directory containing `fontconfig.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'fontconfig' found
  Package fontconfig was not found in the pkg-config search path.
  Perhaps you should add the directory containing `fontconfig.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'fontconfig' found
  ', /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/servo-fontconfig-sys-5.1.0/build.rs:34:17
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/09c42c45858d5f3aedfa670698275303a3d19afa/library/std/src/panicking.rs:517:5
     1: std::panicking::begin_panic_fmt
               at /rustc/09c42c45858d5f3aedfa670698275303a3d19afa/library/std/src/panicking.rs:460:5
     2: build_script_build::main
               at ./build.rs:34:17
     3: core::ops::function::FnOnce::call_once
               at /rustc/09c42c45858d5f3aedfa670698275303a3d19afa/library/core/src/ops/function.rs:227:5
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

I installed all the dependencies for ubuntu specified here

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 22 (6 by maintainers)

Most upvoted comments

I’m on ubuntu and wasn’t willing to install brew to solve this issue as suggested, doesn’t make sense to me.

Using apt to install the dependencies didn’t resolve properly and I used aptitude instead to fix:

sudo aptitude install libfontconfig1-dev libfontconfig

This solved the errors output from pkg-config --libs --cflags fontconfig and pkg-config --modversion fontconfig and thus the original error

Posting here hoping it might help someone in future,

For anyone who finds this in the future without Linux brew or aptitude, I fixed it by just installing one package: sudo apt install libfontconfig1-dev

So.

  • I have symlinked /usr/lib/x86_64-linux-gnu/pkgconfig/fontconfig.pc to /usr/share/pkgconfig, because this seems to be the path pkgconfig looks up by default.
  • It didn’t work.
  • I checked the paths to other packages by running pkg-config --libs --cflags [package]
  • They all pointed to linuxbrew, which is weird
  • I ran brew install fontconfig and now pkg-config can find this package
  • cargo build succeeds

Apparently, Brew somehow messes up pkg-config.

fontconfig-devel for fedora resolved it for me.

I had an issue with running linuxbrew on my ubuntu system.

Running export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig after doing a brew install fontconfig fixed it for me