Skip to content
This repository has been archived by the owner on Sep 4, 2022. It is now read-only.

Show a more helpful error message if pkg-config failed to execute #440

Merged
merged 1 commit into from Nov 24, 2020

Conversation

kpcyrd
Copy link
Member

@kpcyrd kpcyrd commented Oct 25, 2020

Before

error: failed to run custom build command for `libsodium-sys v0.2.6 (/sodiumoxide/libsodium-sys)`

Caused by:
  process didn't exit successfully: `/sodiumoxide/target/debug/build/libsodium-sys-e518d918bc369c57/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=SODIUM_LIB_DIR
cargo:rerun-if-env-changed=SODIUM_SHARED
cargo:rerun-if-env-changed=SODIUM_USE_PKG_CONFIG
cargo:rerun-if-env-changed=SODIUM_DISABLE_PIE
cargo:rerun-if-env-changed=LIBSODIUM_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=LIBSODIUM_STATIC
cargo:rerun-if-env-changed=LIBSODIUM_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 'Error: Command { command: "\"pkg-config\" \"--libs\" \"--cflags\" \"libsodium\"", cause: Os { code: 2, kind: NotFound, message: "No such file or directory" } }', libsodium-sys/build.rs:115:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

After

error: failed to run custom build command for `libsodium-sys v0.2.6 (/sodiumoxide/libsodium-sys)`

Caused by:
  process didn't exit successfully: `/sodiumoxide/target/debug/build/libsodium-sys-e518d918bc369c57/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=SODIUM_LIB_DIR
cargo:rerun-if-env-changed=SODIUM_SHARED
cargo:rerun-if-env-changed=SODIUM_USE_PKG_CONFIG
cargo:rerun-if-env-changed=SODIUM_DISABLE_PIE
cargo:rerun-if-env-changed=LIBSODIUM_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=LIBSODIUM_STATIC
cargo:rerun-if-env-changed=LIBSODIUM_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 '
Failed to run pkg-config:
Command { command: "\"pkg-config\" \"--libs\" \"--cflags\" \"libsodium\"", cause: Os { code: 2, kind: NotFound, message: "No such file or directory" } }

You can try fixing this by installing pkg-config:

    # On Ubuntu
    sudo apt install pkg-config
    # On Arch Linux
    sudo pacman -S pkgconf
    # On Fedora
    sudo dnf install pkgconf-pkg-config

', libsodium-sys/build.rs:115:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This is inspired by openssl-sys, which does something similar.

kpp
kpp previously approved these changes Oct 25, 2020
@kpcyrd
Copy link
Member Author

kpcyrd commented Oct 25, 2020

bors r+

bors bot added a commit that referenced this pull request Oct 25, 2020
440: Show a more helpful error message if pkg-config failed to execute r=kpcyrd a=kpcyrd

## Before
```
error: failed to run custom build command for `libsodium-sys v0.2.6 (/sodiumoxide/libsodium-sys)`

Caused by:
  process didn't exit successfully: `/sodiumoxide/target/debug/build/libsodium-sys-e518d918bc369c57/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=SODIUM_LIB_DIR
cargo:rerun-if-env-changed=SODIUM_SHARED
cargo:rerun-if-env-changed=SODIUM_USE_PKG_CONFIG
cargo:rerun-if-env-changed=SODIUM_DISABLE_PIE
cargo:rerun-if-env-changed=LIBSODIUM_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=LIBSODIUM_STATIC
cargo:rerun-if-env-changed=LIBSODIUM_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 'Error: Command { command: "\"pkg-config\" \"--libs\" \"--cflags\" \"libsodium\"", cause: Os { code: 2, kind: NotFound, message: "No such file or directory" } }', libsodium-sys/build.rs:115:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

## After
```
error: failed to run custom build command for `libsodium-sys v0.2.6 (/sodiumoxide/libsodium-sys)`

Caused by:
  process didn't exit successfully: `/sodiumoxide/target/debug/build/libsodium-sys-e518d918bc369c57/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=SODIUM_LIB_DIR
cargo:rerun-if-env-changed=SODIUM_SHARED
cargo:rerun-if-env-changed=SODIUM_USE_PKG_CONFIG
cargo:rerun-if-env-changed=SODIUM_DISABLE_PIE
cargo:rerun-if-env-changed=LIBSODIUM_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=LIBSODIUM_STATIC
cargo:rerun-if-env-changed=LIBSODIUM_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 '
Failed to run pkg-config:
Command { command: "\"pkg-config\" \"--libs\" \"--cflags\" \"libsodium\"", cause: Os { code: 2, kind: NotFound, message: "No such file or directory" } }

You can try fixing this by installing pkg-config:

    # On Ubuntu
    sudo apt install pkg-config
    # On Arch Linux
    sudo pacman -S pkgconf
    # On Fedora
    sudo dnf install pkgconf-pkg-config

', libsodium-sys/build.rs:115:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

This is inspired by openssl-sys, which does something [similar](https://github.com/sfackler/rust-openssl/blob/e796b76e473ff244c2eb0545000361ce9a20b0da/openssl-sys/build/main.rs#L140-L163).

Co-authored-by: kpcyrd <git@rxv.cc>
@bors
Copy link
Contributor

bors bot commented Oct 25, 2020

Timed out.

@kpp
Copy link
Member

kpp commented Oct 25, 2020

No way...

@kpp
Copy link
Member

kpp commented Nov 19, 2020

Ping?

@kpcyrd
Copy link
Member Author

kpcyrd commented Nov 19, 2020

This looks a bit like a rustc regression, the tests are probably also broken on master.

@kpp
Copy link
Member

kpp commented Nov 19, 2020

What shall we do then?

@Dylan-DPC-zz
Copy link
Member

We can retry it. if regression still exists (on latest rust version) we need to create an issue about it on rust-lang/rust

@kpcyrd
Copy link
Member Author

kpcyrd commented Nov 19, 2020

Our master branch also has broken tests on nightly and beta started failing here too after the recent 1.48.0 rust release. I've asked in ##rust on freenode and they asked if we could provide a reduced test-case.

@kpp
Copy link
Member

kpp commented Nov 24, 2020

bors: r+

@bors
Copy link
Contributor

bors bot commented Nov 24, 2020

Build succeeded:

@bors bors bot merged commit 02b61de into master Nov 24, 2020
@bors bors bot deleted the helpful-pkg-config-error branch November 24, 2020 09:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants