prixt
prixt

Reputation: 61

How can I install and connect the alsa.pc when building the 'alsa-sys' crate as a dependency?

I'm trying to build a rust binary using travis-ci. I managed to get the windows and osx build working, but the linux build keeps failing.

It seems the 'alsa-sys' crate, one of the dependencies, cannot locate the alsa.pc in the linux-vm.

.travis.yml:

language: rust
cache: cargo
rust:
- stable

matrix:
  allow_failures:
  - rust: nightly
  fast_finish: true
os:
- osx
- windows
- linux

script:
  - cargo build --verbose --release

before_deploy:
- if [[ -f target/release/soundsense-rs ]]; then mv target/release/soundsense-rs "target/release/soundsense-rs-$TRAVIS_TAG-$TRAVIS_OS_NAME"; fi
- if [[ -f target/release/soundsense-rs.exe ]]; then mv target/release/soundsense-rs.exe "target/release/soundsense-rs-$TRAVIS_TAG-$TRAVIS_OS_NAME.exe"; fi

deploy:
- provider: releases
  skip_cleanup: true
  on:
    tags: true
    condition: "$TRAVIS_RUST_VERSION = stable"
    branch: release
  file_glob: true
  file:
  - target/release/soundsense-rs-*
  api_key:
    secure: IRdsT0enLWr2qaa63GPnITLaYdar4vDKcKfo9Fm1PlDoWi1gigTZ2elegApdBQmWzcgdHEtiEayg9KtQw76R/l7bH2Yst3kvZPyd635g6Cwj9XUp70opApLeKdVGQhnvGA2fMehYXNfcLi8wn65th3katabvJhuU26C1ICAFt1ExVu2iDbIjUYPmg5O4f3BAvHYlGe5BNyA3C20sakD25ocp+Z/KaI1gfRdYvm3cwVuci63N2O0c+j2IHkaUg/bfA7XHRUqzxO1U4MNrRyYAwRRiIJ+wgKVh9qISt4N0Uw8IZR8ZmBkeK4OPkh+ggb05ONoOpCuOVDGKqMzbEG0SNKbDpwXdxfCkmbtNeXrORX6ZSlNPJOGaPhrD36WYZdRGOZMNC4lSgev/O2lZ/TfJc1Qj9kXlD7kbmG/vKrSkQYs4i/5p4a93E0zgBfyWiK1wiUYCc01PF5YKjbc0n7aymSO3z3CzGijwykH6MKFnInk1JtJ2aUjBM722oKVuCaW/JDikN4wMgPrlIMUY+dLrXBJZLXra89B/RS6un1NsTO0IPyMDQYKRgp6yTkvWJHux0m0Gwexnc+S/dPhb9Z023UDA0pb504XNc7ggpo9xtb5sUa/z/xQRoX3fKFSUEOoNLI3Kw/DE4QwHmnvVSdOGF4+s3Kj2JqnKSZusq3yycnw=

error message:

     Running `/home/travis/build/prixt/soundsense-rs/target/release/build/alsa-sys-9e3efef5874a428f/build-script-build`

error: failed to run custom build command for `alsa-sys v0.1.2`

Caused by:

  process didn't exit successfully: `/home/travis/build/prixt/soundsense-rs/target/release/build/alsa-sys-9e3efef5874a428f/build-script-build` (exit code: 101)

--- stderr

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "`\"pkg-config\" \"--libs\" \"--cflags\" \"alsa\"` did not exit successfully: exit code: 1\n--- stderr\nPackage alsa was not found in the pkg-config search path.\nPerhaps you should add the directory containing `alsa.pc\'\nto the PKG_CONFIG_PATH environment variable\nNo package \'alsa\' found\n"', src/libcore/result.rs:999:5

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

warning: build failed, waiting for other jobs to finish...

error: build failed

The command "cargo build --verbose --release" exited with 101.

What commands do I need to add to solve this?

Upvotes: 5

Views: 4916

Answers (1)

prixt
prixt

Reputation: 61

Following the advice by @Jmb, I added some package installing commands during the before_install step:

before_install:
  - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install -y libasound2-dev ; sudo apt-get install -y libwebkit2gtk-4.0 ; fi

(I also needed to install the libwebkit2gtk package for another dependency) This solved the issue.

Upvotes: 1

Related Questions