Permission issue with "cargo cinstall"


I'm sure this is an easy question for the devs here.

I'm compiling the rust extensions for GStreamer on a Raspberry PI: net/webrtc · main · GStreamer / gst-plugins-rs · GitLab

The README states this for build and install for a particular module:

The plugin can also be installed system-wide:

$ cargo cbuild -p gst-plugin-cdg --prefix=/usr
$ cargo cinstall -p gst-plugin-cdg --prefix=/usr

Not surprisingly I'm facing a permission issue in the "install" step:

Error: CliError { error: Some(failed to copy `/home/pi/gst-plugins-rs/target/aarch64-unknown-linux-gnu/release/gstrswebrtc.pc` to `/usr/local/lib/aarch64-linux-gnu/pkgconfig/gstrswebrtc.pc`

Caused by:
    Permission denied (os error 13)), exit_code: 101 }

Rust is installed to my home directory, so the permission issue is ok. "sudo cargo" doesn't work either.

I could help myself meanwhile with this, but I don't like that much honestly:

sudo chown pi /usr/local/lib/aarch64-linux-gnu/

Then the install works and the module is really there and usable.

Question is: Is there another way to tackle the permission issue?

Use --prefix=./some_local_dir (or perhaps --destdir) to install it locally and then move things afterwards (with sudo) if it checks out, or if you trust it enough,

sudo cargo cinstall -p gst-plugin-cdg --prefix=/usr

Thanks, but I don't have a rust installation for "sudo". Should I install it additionally as sudo then? Is that recommended?

I'm not sure how to interpret that.

What I meant in more general terms is, use sudo to perform the execution that gives you a permission error instead of using sudo to chown pi /usr/local/lib/aarch64-linux-gnu/.

Nevermind. I meant, there is no cargo if I prefix it with sudo. Like sudo cargo gives not found or something. But disregard please, I'm over it