---
title: Snapcraft offline mode – Build snaps while saving data
description: As part of the snap creation cycle, the Snapcraft tool creates isolated
  build instances inside which all of the necessary work – download of sources, compilation,
  packaging, etc. – is done in a safe manner, without touching the host system. While
  there are many advantages to the use of the virtual machines (via Multipass) or  […]
url: https://canonical.com/blog/snapcraft-offline-mode-build-snaps-while-saving-data?format=md
---

1. [Blog](https://canonical.com/blog)
2. Article

---

[Igor Ljubuncic](https://canonical.com/blog/author/igorljubuncic "More about Igor Ljubuncic")

12 November 2021

# Snapcraft offline mode – Build snaps while saving data

[build](https://canonical.com/blog/tag/build)
[experimental](https://canonical.com/blog/tag/experimental)
[offline](https://canonical.com/blog/tag/offline)
[snapcraft](https://canonical.com/blog/tag/snapcraft)
[snapcraft.io](https://canonical.com/blog/tag/snapcraft-io)
[Snaps](https://canonical.com/blog/tag/snaps)

---

Share the article

As part of the snap creation cycle, the Snapcraft tool creates isolated build instances inside which all of the necessary work – download of sources, compilation, packaging, etc. – is done in a safe manner, without touching the host system. While there are many advantages to the use of the virtual machines (via Multipass) or containers (via LXD) for these tasks, the downside is a fairly liberal use of the network bandwidth to setup and configure the Snapcraft work environment.

In some scenarios, you may be constrained in your available network throughput or data. To help with that, the latest build of Snapcraft comes with a new, experimental offline mode, designed to minimize the reliance on online sources, and allow you to continue working and building snaps even if you have no access to the network.

# The basics

To run Snapcraft in the offline mode, simply pass the –offline flag to the Snapcraft command-line tool. However, there are a few important things to take into consideration first.

* Snapcraft cannot magically spawn the necessary data out of nothing. It needs the initial pull of the relevant sources, including the build images (say Ubuntu 18.04 or Ubuntu 20.04 container images), the sources for your software, any additional build or stage packages that will be used, and other assets that your application relies on.
* To get the necessary data for subsequent offline runs, run *snapcraft pull*. This will download the assets once and cache them for later use.

Now, with or without the network connection, you can run Snapcraft in the offline mode. It will rely on the downloaded data for the build, and will not try to contact the online archives and grab any new packages. The final objective is to allow users to be able to iterate on their builds without consuming additional data.

On the other hand, if you discover you rely on new components that do not exist in your cache, you may have to re-run Snapcraft in its standard (online) mode again at some point. You will also not receive any updates or patches to libraries (depending on how long you stay in the offline mode).

# Example

I tried to build a snap that uses the core20 base. The initial download weighed 143 MB. After that, Snapcraft did not use or download any new sources. I was then able to make modifications to the snapcraft.yaml file and build the snap. Of course, these changes did not rely on additional data from the Internet.

```
snapcraft pull
Launching a VM.
2021-11-10T12:30:13Z INFO Waiting for automatic snapd restart…
snapd 2.52.1 from Canonical✓ installed
core20 20210928 from Canonical✓ installed
"core20" switched to the "latest/stable" channel
snapcraft 6.0 from Canonical✓ installed
"snapcraft" switched to the "latest/edge" channel
snapd is not logged in, snap install commands will use sudo
snap "core20" has no updates available
Pulling segfexample
+ snapcraftctl pull
```

```
snapcraft --use-lxd --offline
*EXPERIMENTAL* --offline enabled.
Launching a container.
Waiting for container to be ready
...
```

```
...
*EXPERIMENTAL* --offline enabled.
Offline mode, not installing build packages.
...
```

You can also always try to use the –offline mode while connected to the network. In the current *experimental* implementation, Snapcraft may make some assumptions for you, and may perform an initial download & cache of relevant data on first run even if you do not manually specify the *pull* command.

# Summary

The offline mode is a handy addition to the arsenal of capabilities available in Snapcraft, and it should help with scenarios where data usage should be as low as possible. The functionality is still in experimental mode, so if you’d like to test it, or have any ideas or suggestions, or if you find any bugs, please tell us in [the forum](https://forum.snapcraft.io/). For instance, you might want to know if cached data can be reused across systems, how to perform partial updates of online sources, or similar. We welcome feedback, and we’re interested in learning more about how we can further simplify and enhance the developer experience with Snapcraft.

Photo by [Markus Spiske](https://unsplash.com/@markusspiske?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/s/photos/matrix?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText).

[Get in touch

Interested in running Ubuntu in your organization?](https://ubuntu.com/about/contact-us/form)

## Sign up for our newsletter

Get the latest Canonical news and updates in your inbox.

Work email:

\*I agree to receive information about Canonical's
products and services.

By submitting this form, I confirm that I have read and agree to [Canonical's Privacy Policy](https://canonical.com/legal/dataprivacy).

Sign up

## Share on

---

## Related posts

[### TurtleBot3 OpenCR firmware update from a snap](https://canonical.com/blog/turtlebot3-opencr-firmware-update-from-a-snap)

The TurtleBot3 robot is a standard platform robot in the ROS community, and it’s a reference that Canonical knows well, since we’ve used it in our tutorials. As a matter of...

[gbeuzeboc](https://canonical.com/blog/author/gbeuzeboc)

25 September 2024

[### Managing software in complex network environments: the Snap Store Proxy](https://canonical.com/blog/managing-software-snap-store-proxy)

As enterprises grapple with the evolving landscape of security threats, the need to safeguard internal networks from the broader internet is increasingly important. In...

[Holly Hall](https://canonical.com/blog/author/hollyhall)

15 January 2024

[### Space pioneers: Lonestar gears up to create a data centre on the Moon](https://canonical.com/blog/lonestar-data-centre-moon)

Why establish a data centre on the Moon? Find out in our blog.

[Rhys Knipe](https://canonical.com/blog/author/rhysknipe)

12 June 2024

[### Creating Snaps on Ubuntu Touch](https://canonical.com/blog/creating-snaps-on-ubuntu-touch)

This article was written in collaboration with Alfred E. Neumayer of the UBports Project. Tablets, phones and current technology’s capabilities are phenomenal. Who would have...

[Aaron Prisk](https://canonical.com/blog/author/aaronprisk)

3 April 2024
