I am trying to package a rust application as a snap.
I have installed snapcraft with
snap install snapcraft --classic as described here: https://snapcraft.io/first-snap/rust.
The first time executing snapcraft it creates a new multipass instance an then builds the snap successfully.
But when I try to rebuild the snap I get this error
/root/.cargo/bin/cargo +stable install --path /root/parts/xsv/build --root /root/parts/xsv/install Installing xsv v0.13.0 (/root/parts/xsv/build) error: binary `xsv` already exists in destination as part of `xsv v0.13.0 (/root/parts/xsv/build)` Add --force to overwrite Failed to run '/root/.cargo/bin/cargo +stable install --path /root/parts/xsv/build --root /root/parts/xsv/install' for 'xsv': Exited with code 101. Verify that the part is using the correct parameters and try again.
This happens both with my rust app and the
xsv app documented in this guide: https://snapcraft.io/first-snap/rust/linux/package.
I think this happens because it is reusing the multipass instance and rerunning some form of
cargo install. By default cargo will not overwrite an existing binary with cargo install. So you have to pass
--force to do that, which is what it suggests. However I have no idea how to get snapcraft to pass this flag to cargo and I don’t want to delete and rebuild the multipass instance every time.
I have been unable to find any reference to this issue by googling.
Is there a way to pass parameters to cargo or anything else I am missing?