Snapcraft Network Error (seemingly with all Core22)

Hey All,

I’m just starting out with Snapcraft and am unfortunately encountering a seemingly simple issue that I’m having problems resolving. To get started, I’ve begun experimenting with some tutorials laid out in the documentation. In particular, I’m starting with the ROS2 example ( Every time I try to build the snap, I get this error:

  File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_providers/bases/", line 617, in _setup_apt
    _execute_run(executor, ["apt-get", "update"], verify_network=True)
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_providers/bases/", line 135, in _execute_run
    raise NetworkError() from exc

Now an important note is I’m only encountering this error with Core22 variation of this snap. I tested the core20 release and that seems to work fine (ignoring the gpg keyserver error I see but that is a separate problem). I also tested the DOSbox example which uses Core18 and that was able to successfully generate a snap.

Curious to know if anyone has any idea what is causing this or if anyone has a solution? I am on snapcraft 7.3.1 for reference. Also, here is the full stack trace:

xps:~/ros2-talker-listener-core22$ snapcraft
Launching instance... | (48.3s)                                                                                                                                            Traceback (most recent call last):
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_providers/bases/", line 130, in _execute_run
    proc = executor.execute_run(
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_providers/lxd/", line 289, in execute_run
    return self.lxc.exec(
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_providers/lxd/", line 410, in exec
    return runner(final_cmd, **kwargs)  # pylint: disable=subprocess-run-check
  File "/snap/snapcraft/8931/usr/lib/python3.8/", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['lxc', '--project', 'snapcraft', 'exec', 'local:snapcraft-ros2-talker-listener-on-amd64-for-amd64-28385441', '--', 'env', 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin', 'SNAPCRAFT_MANAGED_MODE=1', 'apt-get', 'update']' returned non-zero exit status 100.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/snap/snapcraft/8931/bin/snapcraft", line 8, in <module>
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/snapcraft/", line 243, in run
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/snapcraft/", line 219, in _run_dispatcher
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_cli/", line 448, in run
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/snapcraft/commands/", line 259, in run
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/snapcraft/commands/", line 132, in run, parsed_args)
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/snapcraft/parts/", line 215, in run
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/snapcraft/parts/", line 256, in _run_command
    _run_in_provider(project, command_name, parsed_args)
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/snapcraft/parts/", line 540, in _run_in_provider
    with provider.launched_environment(
  File "/snap/snapcraft/8931/usr/lib/python3.8/", line 113, in __enter__
    return next(self.gen)
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_providers/lxd/", line 126, in launched_environment
    instance = launch(
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_providers/lxd/", line 524, in launch
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_providers/lxd/", line 74, in _create_instance
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_providers/bases/", line 410, in setup
    self._setup_apt(executor=executor, deadline=deadline)
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_providers/bases/", line 617, in _setup_apt
    _execute_run(executor, ["apt-get", "update"], verify_network=True)
  File "/snap/snapcraft/8931/lib/python3.8/site-packages/craft_providers/bases/", line 135, in _execute_run
    raise NetworkError() from exc
craft_providers.bases.errors.NetworkError: A network related operation failed in a context of no network access.
Verify that the environment has internet connectivity; see for further reference.
1 Like

Hi @Seiwert, welcome!

Exit code 100 from apt-get update is a challenging error to track down. I couldn’t reproduce it.
Often these networking errors are caused by Docker interfering with the IP tables on your host machine. There is some information available here:

For error code 100, it could be something transient. Try running snapcraft clean; perhaps apt got in a bad state.

On a side note, I created an issue to make the error output more useful.

I’m having exact the same issue, but the ROS2 example builds if I a bypass the lxd stuff with

sudo snapcraft --destructive-mode --enable-experimental-extensions

but I this might not be a good solution, because then changes are made to my system are made. I’m running snapcraft 7.3.1 in 22.04.2 LTS inside a Virtual Box with bridged network, so network issue may not be the root cause. :frowning:

i my case it really seems that the lxd setup is incorrectly done, but I did exact the step from the ros humble tutorial.

Also a very basis hello snap fails with same, why this snap needs to install git is mystery to me but if fails the same way as the ROS2 example for canonical webpage:

subprocess.CalledProcessError: Command '['lxc', '--project', 'snapcraft', 'exec', 'local:snapcraft-hello-snap-on-amd64-for-amd64-788796', '-

-', 'env', 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin', 'SNAPCRAFT_MANAGED_MODE=1', 'apt-get', 'install',

'-y', 'apt-utils', 'curl', 'gnupg', 'dirmngr', 'git']' returned non-zero exit status 100.

name: hello-snap
version: '0.1'
summary: Greeter snap to write a "Hello"
description: |
  This example wrtites hello with bash.

base: core22
confinement: strict

command: /bin/bash /opt/hello.bash
plugs: [network, network-bind]

plugin: dump
  - bash
source: ./
  hello.bash: /opt/

Long Story shot, How to setup LXD corretly for snapcraft?

sudo snap install lxd
sudo lxd init --minimal

seems not to be the right way to go

Exit code 100 from apt-get update

as a workaround on some freshly installed system I got rid of this error by switching network on host system from nat to not-nat configuratiuon, it didn’t work via lxc nat + host system nat for some not totally clear reason

I know it is a bit of an old thread, but is there any chance you also have Docker installed? It installs some firewall rules that interfere with LXD’s networking. There’s some details here:

1 Like