How to properly setup the rust / cargo environment to build packages

tachang

New Member
Jun 29, 2020
8
0
1
43
I am running into issues trying to build pve-qemu. Specifically it is asking for a package:

dpkg-checkbuilddeps: error: Unmet build dependencies: check libproxmox-backup-qemu0-dev (>= 0.2.0-1)

Thinking the debian package can be built using the git repo proxmox-backup-qemu I checked that out and proceeded to try and make.
However I ran into an issue with cargo/rust.

In the readme it states:

Code:
Local cargo config
==================

This repository ships with a ``.cargo/config`` that replaces the crates.io
registry with packaged crates located in ``/usr/share/cargo/registry``.

A similar config is also applied building with dh_cargo. Cargo.lock needs to be
deleted when switching between packaged crates and crates.io, since the
checksums are not compatible.

To reference new dependencies (or updated versions) that are not yet packaged,
the dependency needs to point directly to a path or git source.

However I am not sure how to proceed here. I see

Code:
# cat .cargo/config
[source]
[source.debian-packages]
directory = "/usr/share/cargo/registry"
[source.crates-io]
replace-with = "debian-packages"

So when I run cargo it will replace crate-io with the local registry. However my local registry is empty and does not even exist.


# ls -al /usr/share/cargo/registry

ls: cannot access '/usr/share/cargo/registry': No such file or directory


A make results in:

Code:
# make
cargo test
error: failed to get `anyhow` as a dependency of package `proxmox v0.1.41 (/root/workspace/proxmox/proxmox)`

Caused by:
  failed to load source for dependency `anyhow`

Caused by:
  Unable to update registry `https://github.com/rust-lang/crates.io-index`

Caused by:
  failed to update replaced source registry `https://github.com/rust-lang/crates.io-index`

Caused by:
  failed to read root of directory source: /usr/share/cargo/registry

Caused by:
  No such file or directory (os error 2)

Which makes sense since it is trying to find the package `anyhow` in the local registry.

What's the best way to proceed in getting a proper environment up and running to build these debian packages?
 
Add the PBS repository
Code:
deb http://download.proxmox.com/debian/pbs buster pbstest
Then, pull the proxmox-backup git repository and try
Code:
mk-build-deps
apt install ./rust-proxmox-backup-build-deps_0.8.9-1_all.deb
make dinstall
 
actually libproxmox-backup-qemu-dev is available via the regular PVE repositories..
 
# ls -al /usr/share/cargo/registry

ls: cannot access '/usr/share/cargo/registry': No such file or directory

Apparently this directory is created when you install a Debian-packaged Rust package. So to solve this missing "anyhow" library, run apt install librust-anyhow-dev. It'll create that /usr/share/cargo/registry directory for you and store it in there for you.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!