rust plugin: fix cargo builds and run tests
Metadata
Current evaluation
Changes to fix cargo builds and add tests to the Rust plugin were closed and superseded by PR #2170 after the author discovered cargo test conflicts with cross-compilation, requiring a rework.
Suggested action: —
No scores available.
Issue body
This patch changes it so that we run all instances of cargo using the build environment. Fixes cases where a snap cleanbuild will error out with rustc being unable to be found during the pull step.
This is the issue I asked for help with on the forum: [https://forum.snapcraft.io/t/problem-building-rust-based-snap/5776](https://forum.snapcraft.io/t/problem-building-rust-based-snap/5776)
Also adds 'cargo test' to the build step, to fail the build if the tests aren't passing.
Rust plugin unittests have been updated.
- [ ] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [ ] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [ ] If this is a bugfix. Have you checked that there is a bug report open for the issue you are trying to fix on [bug reports](https://bugs.launchpad.net/snapcraft)?
- [ ] If this is a new feature. Have you discussed the design on the [forum](https://forum.snapcraft.io)?
- [ ] Have you successfully run `./runtests.sh static`?
- [ ] Have you successfully run `./runtests.sh unit`?
-----
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Changes to fix cargo builds and add tests to the Rust plugin were closed and superseded by PR #2170 after the author discovered cargo test conflicts with cross-compilation, requiring a rework. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Superseded by PR #2170. Changes to fix cargo builds and integrate tests were reworked to resolve cross-compilation conflicts and CI branch issues, then reopened as a new pull request. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Superseded by PR #2170. The original pull request fixed rust plugin cargo build environment issues and added cargo test, but was closed due to cross-compilation conflicts and CI branch errors. The maintainer recreated the changes in the new PR. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #2170 rust plugin: fix cargo builds and run tests | snapcraft | merged | Merged fixes for cargo builds in the Rust plugin along with new tests. The change updated two files with 41 additions and 10 deletions, achieving 100% diff coverage. | |
| #1015 rust plugin does not cross-compile | craft-parts | open | Rust plugin builds for host arch instead of target arch when cross-compiling. Triaged by maintainer with a fix plan (map arch to rust triple, rustup target add, set CARGO_BUILD_TARGET); a working PR branch was shared Aug 2025, but no fix has landed in craft-parts yet. | |
| #560 rust_plugin: multiple fixes | craft-parts | merged | Merged Rust plugin fixes resolving issue #559. Changes remove unnecessary rust_channel override typing checks and improve compiler plugin identification and removal. Approved by reviewers and merged despite an unrelated CI pylint failure. | |
| #2434 rust plugin: refactor to use the latest rustup | snapcraft | merged | Merged Rust plugin refactor for latest rustup. Removed deprecated flags, added command qualifiers, established shared rustup/cargo directory, and standardized config. Approved and passed CI. | |
| #2917 rust plugin: fetch correct (locked) crates during pull | snapcraft | merged | Merged fix for the rust plugin that corrected crate version fetching during pull by checking for Cargo.lock in the source directory instead of the build directory. Updated spread test to prevent regression. | |
| #2431 rust plugin: update to use latest rustup command options | snapcraft | merged | Merged update to the Rust plugin replacing deprecated rustup command options with current equivalents. Approved by a reviewer, passed CI, modified five files, and maintained 94.5% test coverage. | |
| #1561 rust plugin: record the Cargo.lock file | snapcraft | merged | Merged to record the Cargo.lock file in the Rust plugin, addressing issue #1475. Approved by two reviewers, passed CI checks, and modified two files (+85/-21 lines). | |
| #952 rust plugin: add features for conditional compilation | snapcraft | closed | Superseded by pull request #1029, which added the requested unit tests and merged the Rust plugin conditional compilation feature. The original contribution was successfully integrated. | |
| #2849 rust plugin: split RUSTUP_HOME and CARGO_HOME | snapcraft | merged | Merged Rust plugin changes decoupling RUSTUP_HOME and CARGO_HOME. Previously both defaulted to ~/.cargo, risking side effects. They now point to ~/.rustup and ~/.cargo respectively. Approved and passed CI. | |
| #570 rust_plugin: multiple fixes (#560) | craft-parts | merged | Merged as #560. The rust_plugin was updated to remove compiler plugins from final Snap packages and eliminate a redundant channel override causing type-checking errors. Approved by one reviewer and passed CI checks. |