← Back to issue list

rust plugin crashes when trying to rebuild a snap package

View original Launchpad issue

Metadata

Project
snapcraft (launchpad)
Number
#1825858
Type
issue
State
closed
Author
~shahn
Labels
rust
Created
Updated
Closed

Current evaluation

Rust plugin rebuilt via `cargo install` without `--force`, so re-running snapcraft failed. Fixed by merged PR snapcore/snapcraft#2620 (commit 601bd2df7), which adds `--force` to cargo args.

Resolution: closed resolved

Reason: A fix proposed by ~chris.macnaughton landed in snapcore/snapcraft#2620 (commit 601bd2df7), adding Cargo's `--force` flag to the rust plugin install step so binaries are overwritten on rebuild. The bug was that the second `snapcraft` run aborted with "binary already exists in destination"; `--force` removes the need for `snapcraft clean`.

Evaluated by: mr-cal-bot

No scores available.

Issue body

To reproduce: - create a rust project that will build and install executables (e.g. with `cargo init --bin`) - add a snapcraft.yaml using the rust plugin - run `snapcraft` (this works) - run `snapcraft` again. This fails with: ``` /root/.cargo/bin/cargo +stable install --path /root/parts/scriptkeeper/build --root /root/parts/scriptkeeper/install Installing scriptkeeper v0.1.0 (/root/parts/scriptkeeper/build) error: binary `scriptkeeper` already exists in destination as part of `scriptkeeper v0.1.0 (/root/parts/scriptkeeper/build)` Add --force to overwrite ``` It seems as if the plugin runs `cargo install` on the same virtual machine, but that fails the second time, because `cargo` prevents you from overwriting executables without passing `--force`. `snapcraft clean scriptkeeper` fixes this, but it also means that I have to rebuild the entire project for every little change. Which is annoying when trying to debug the snap file. Here's the project and commit where I'm seeing this: https://github.com/Originate/scriptkeeper/commit/2160eeeada5a44546e743f11a90798c8c19083e5 Using: - snapcraft, version 3.4 - multipass 0.6.0 - multipassd 0.6.0 - Ubuntu 18.10 - base: core18

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Rust plugin rebuilt via `cargo install` without `--force`, so re-running snapcraft failed. Fixed by merged PR snapcore/snapcraft#2620 (commit 601bd2df7), which adds `--force` to cargo args.
stealth/space-bunny-alpha — closed resolved Rust plugin rebuild failures were fixed by merged PR #2620 (commit 601bd2df7), which adds Cargo's --force option so existing installed binaries are overwritten.
stealth/space-bunny-alpha — closed resolved Fixed by merged PR #2620 (601bd2df7), which added --force to Cargo install so Rust projects could rebuild without snapcraft clean.
qwen/qwen3.6-35b-a3b — — Closed without resolution. The rust plugin crashed on incremental builds because cargo install refused to overwrite binaries without the --force flag.
qwen/qwen3.6-35b-a3b — — Closed without resolution. Rebuilding fails because cargo install lacks the --force flag to overwrite existing binaries, forcing manual cleanup or snapcraft clean between builds.
qwen/qwen3.6-35b-a3b — — Closed without resolution. The report detailed a Rust plugin failure during snap rebuilds caused by cargo install refusing to overwrite existing binaries. With zero comments and no patch provided, the issue appears abandoned.
qwen3.6-35b-a3b-mtp-q6 — — Closed without resolution or comments. The rust plugin fails on repeated builds because cargo install lacks --force. The issue appears abandoned or superseded by later updates.

Update history

Date Change
created

Related work

  • Likely Fixed By: canonical/snapcraft#2620 (confidence 96%)

    Merged PR titled 'Update Rust plugin to be able to rebuild'; commit 601bd2df7 adds Cargo's --force option.

  • Related To: snapcraft (launchpad)#1825858 (confidence 60%)

    Forum workaround (override-build rm of existing binary) referenced in a user comment as interim fix for the same rebuild problem.

Related issues

Issue Project State Summary Similarity
#2158 rust plugin: fix cargo builds and run tests snapcraft closed PR closed as superseded: the rust-plugin-improvements branch was deleted and the work was reworked and merged as snapcore/snapcraft#2170 (commit 4f80a1051) after cargo test broke cross-compilation.
76%
#2620 Update Rust plugin to be able to rebuild snapcraft merged Merged PR #2620 (commit 601bd2df7) added Cargo's --force option so Rust projects can rebuild without clearing the compiler cache; resolves LP #1825858.
72%