Problem building rust based snap

Hi

I’m trying to build a rust based package on build.snapcraft.io, and I’m having troubles getting off the ground.

What I think is happening is that during the pull phase, the rust plugin first installs rust (which works) and then tries to fetch dependencies (using cargo).
Then when it runs cargo, it can’t find rustc (because it’s been installed to a specific directory that’s not in the path).

I’m not sure what I’m doing differently to any other rust-based snap out there, so I wonder what I need to do to make progress.

The repo is at:

And an example failure is here:

Any advice will be appreciated!

Ok - somewhat answered now.

I ended up customizing the rust plugin with a local plugin and changing it so that all invocations of cargo use the custom environment and that seems to work for me.

While I was there, I added a cargo test before the cargo install.

Source is here: https://github.com/tismith/device-checkout-rs/blob/master/snap/plugins/x_rust.py

2 Likes

This looks like a bug to the rust plugin of snapcraft, maybe file a bug on Bugs : Snapcraft?

Also I’d like to ask is it possible to increase the retry count of downloading libraries from crates.io?

The default of 3 reaches easily at my end.

@Lin-Buo-Ren Thanks for confirming that the fix I suggested works! I’ve already raised a pull request for this fix over here: https://github.com/snapcore/snapcraft/pull/2158

2 Likes