oSumAtrIX / DownOnSpot

🎧 A Spotify music and playlist downloader working with free Spotify accounts written in Rust
https://osumatrix.me
GNU General Public License v3.0
548 stars 45 forks source link

Cargo Build on Ubuntu 22.04: `failed to run custom build for command alsa-sys v0.3.1` #69

Closed ebb-earl-co closed 6 months ago

ebb-earl-co commented 7 months ago

Describe the bug I am running Pop!_OS 22.04 and cargo 1.74.0, installed. Upon cloning the repository, I changed the free-librespot line in Cargo.toml as mentioned in the README.md. However, upon trying to build the project with cargo build --release, I ran into the following exception:

error: could not find system library 'alsa' required by the 'alsa-sys' crate

To Reproduce Steps to reproduce the behavior:

  1. Clone DownOnSpot to a user-writable directory
  2. Edit Cargo.toml to replace "ssh://git@github.com/oSumAtrIX/free-librespot.git" with librespot = "0.4.2"
  3. Using cargo version 1.74.0, run cargo build --release from just-cloned directory root
  4. See error

Expected behavior I expected to hit the [libmp3lame](https://www.rarewares.org/mp3-lame-libraries.php#libmp3lame) error mentioned in the doc, because I know that I don't have that library installed. However, I was not expecting to get an error to do with ALSA, as Pop!_OS 22.04 ships with pipewire-alsa by default (or, at least, it was installed before attemping cargo build --release).

Screenshots Screenshot from 2023-12-02 22-25-33

Desktop (please complete the following information):

Additional context After search engine-ing the error, I came across the spotifyd project, and in a GitHub issue for that project was the answer I needed. It turns out that the librust-alsa-sys-dev package was necessary from APT. HOWEVER once I installed the aforementioned ALSA-related package, upon trying cargo build --release again, I hit an error to do with libmp3lame: Screenshot from 2023-12-02 22-30-06

Even though I have libmp3lame0 installed,

libmp3lame0 3.100-3build2 [Ubuntu/jammy main]
├── is installed
└── MP3 encoding library

it turns out that I needed libmp3lame-dev in order to successfully compile. Once I installed libmp3lame-dev, the cargo build --release command exited successfully!

Maybe these steps would be useful in the README.md, in order to help others with Ubuntu-like OSes. Thanks for the project!

oSumAtrIX commented 7 months ago

The crate that fails to build expects system libraries to be present. The official documentstion mentions a different package: https://github.com/diwic/alsa-sys

Can you confirm if this solves the issue?

LeoColman commented 7 months ago

I was having the same issue and can confirm that running

sudo apt install libasound2-dev as suggested by alsa-sys

on Ubuntu 22.04 fixed the issue for me

ebb-earl-co commented 6 months ago

@oSumAtrIX as I said at the end of the original issue, installing librust-alsa-sys-dev was sufficient to build on Ubuntu. I was just hoping to add helpful information to the README by working out the problem and making it an issue here.

oSumAtrIX commented 6 months ago

It is not the correct library and just happened to work, likely due to the correct library being a dependency @LeoColman has already answered.

WMP commented 5 months ago

For my 220.04 this is all dependeny: apt install cargo libmp3lame-dev pkg-config libssl-dev libasound2-dev