Help building a snap containing a rust program

Hi

This is tangentially related to rust itself, but I feel there'll be more rust-appropriate eyes over here on this forum.

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

Specifically, the error I see is that during the pull step, cargo reports that it can't find rustc with the following error:

error: could not execute process `rustc -vV` (never executed)

What I think is happening is that during the pull phase, the rust plugin first installs rust (which looks like it 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.

Is anyone else using build.snapcraft.io to build a rust based package? Have you had any trouble with the plugin not finding rustc?

The repo is at:

https://github.com/tismith/device-checkout-rs

And an example failure is here:

https://build.snapcraft.io/user/tismith/device-checkout-rs/239825

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

Update: I've since put together a pull request for Snapcraft https://github.com/snapcore/snapcraft/pull/2158 that'll hopefully get this fixed in general!