Cache rust toolchain for offline build

Conveniently now I’m hitting that very problem, trying to get some work done on a train. I’m building a rust snap. My laptop isn’t connected to the internet. Between builds my build dependencies were apt autoremove'd so they need to be reinstalled. They are still in snapcraft’s cache, though, so they install quickly. Then the rust part is being pulled and fails, trying to download the toolchain from static.rust-lang.org.

$ cd integration_tests/snaps/rust-hello
$ snapcraft
[...]
Installing build dependencies: [...]
[...]
Preparing to pull rust-hello 
Pulling rust-hello 
Starting new HTTPS connection (1): static.rust-lang.org
HTTPSConnectionPool(host='static.rust-lang.org', port=443): Max retries exceeded with url: /rustup.sh (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f0bf08cc588>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))

It seems like the toolchain should be cached independently from the part I’m building so that I can clean and re-build without downloading all of it repeatedly. This is also relevant for the case where I’m building with different architectures and required to clean in-between.

2 Likes