Help building a snap containing a rust program


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, 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 to build a rust based package? Have you had any trouble with the plugin not finding rustc?

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:

Update: I’ve since put together a pull request for Snapcraft that’ll hopefully get this fixed in general!