Building with snapcraft in docker

I was forgetting to include these:

ENV PATH="/snap/bin:$PATH"
ENV SNAP="/snap/snapcraft/current"
ENV SNAP_NAME="snapcraft"
ENV SNAP_ARCH="amd64"

(Converting them to “export FOO=bar” lines of course.)

But now I’m getting two problems more:

  • “The following snaps are required but not installed as snapcraft is running inside docker or podman container: core18.”
  • A python exception:
Staging foo 
4150 Sorry, an error occurred in Snapcraft:
4151 'utf-8' codec can't encode character '\udcc5' in position 62: surrogates not allowed
4152 Traceback (most recent call last):
4153   File "/snap/snapcraft/current/bin/snapcraft", line 11, in <module>
4154     load_entry_point('snapcraft==3.8', 'console_scripts', 'snapcraft')()
4155   File "/snap/snapcraft/current/lib/python3.5/site-packages/click/core.py", line 764, in __call__
4156     return self.main(*args, **kwargs)
4157   File "/snap/snapcraft/current/lib/python3.5/site-packages/click/core.py", line 717, in main
4158     rv = self.invoke(ctx)
4159   File "/snap/snapcraft/current/lib/python3.5/site-packages/click/core.py", line 1114, in invoke
4160     return Command.invoke(self, ctx)
4161   File "/snap/snapcraft/current/lib/python3.5/site-packages/click/core.py", line 956, in invoke
4162     return ctx.invoke(self.callback, **ctx.params)
4163   File "/snap/snapcraft/current/lib/python3.5/site-packages/click/core.py", line 555, in invoke
4164     return callback(*args, **kwargs)
4165   File "/snap/snapcraft/current/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
4166     return f(get_current_context(), *args, **kwargs)
4167   File "/snap/snapcraft/current/lib/python3.5/site-packages/snapcraft/cli/_runner.py", line 103, in run
4168     snap_command.invoke(ctx)
4169   File "/snap/snapcraft/current/lib/python3.5/site-packages/snapcraft/cli/_command.py", line 87, in invoke
4170     return super().invoke(ctx)
4171   File "/snap/snapcraft/current/lib/python3.5/site-packages/click/core.py", line 956, in invoke
4172     return ctx.invoke(self.callback, **ctx.params)
4173   File "/snap/snapcraft/current/lib/python3.5/site-packages/click/core.py", line 555, in invoke
4174     return callback(*args, **kwargs)
4175   File "/snap/snapcraft/current/lib/python3.5/site-packages/snapcraft/cli/lifecycle.py", line 261, in snap
4176     _execute(steps.PRIME, parts=[], pack_project=True, output=output, **kwargs)
4177   File "/snap/snapcraft/current/lib/python3.5/site-packages/snapcraft/cli/lifecycle.py", line 66, in _execute
4178     lifecycle.execute(step, project_config, parts)
4179   File "/snap/snapcraft/current/lib/python3.5/site-packages/snapcraft/internal/lifecycle/_runner.py", line 94, in execute
4180     executor.run(step, part_names)
4181   File "/snap/snapcraft/current/lib/python3.5/site-packages/snapcraft/internal/lifecycle/_runner.py", line 148, in run
4182     self._handle_step(part_names, part, step, current_step, cli_config)
4183   File "/snap/snapcraft/current/lib/python3.5/site-packages/snapcraft/internal/lifecycle/_runner.py", line 162, in _handle_step
4184     getattr(self, "_run_{}".format(current_step.name))(part)
4185   File "/snap/snapcraft/current/lib/python3.5/site-packages/snapcraft/internal/lifecycle/_runner.py", line 226, in _run_stage
4186     self._run_step(step=steps.STAGE, part=part, progress="Staging")
4187   File "/snap/snapcraft/current/lib/python3.5/site-packages/snapcraft/internal/lifecycle/_runner.py", line 281, in _run_step
4188     getattr(part, step.name)()
4189   File "/snap/snapcraft/current/lib/python3.5/site-packages/snapcraft/internal/pluginhandler/__init__.py", line 740, in stage
4190     self._do_runner_step(steps.STAGE)
4191   File "/snap/snapcraft/current/lib/python3.5/site-packages/snapcraft/internal/pluginhandler/__init__.py", line 242, in _do_runner_step
4192     return getattr(self._runner, "{}".format(step.name))()
4193   File "/snap/snapcraft/current/lib/python3.5/site-packages/snapcraft/internal/pluginhandler/_runner.py", line 84, in stage
4194     "override-stage", self._override_stage_scriptlet, self._stagedir
4195   File "/snap/snapcraft/current/lib/python3.5/site-packages/snapcraft/internal/pluginhandler/_runner.py", line 137, in _run_scriptlet
4196     scriptlet_name, function_call.strip()
4197   File "/snap/snapcraft/current/lib/python3.5/site-packages/snapcraft/internal/pluginhandler/_runner.py", line 193, in _handle_builtin_function
4198     function(**function_args)
4199   File "/snap/snapcraft/current/lib/python3.5/site-packages/snapcraft/internal/pluginhandler/__init__.py", line 767, in _do_stage
4200     self.mark_stage_done(snap_files, snap_dirs)
4201   File "/snap/snapcraft/current/lib/python3.5/site-packages/snapcraft/internal/pluginhandler/__init__.py", line 777, in mark_stage_done
4202     self._scriptlet_metadata[steps.STAGE],
4203   File "/snap/snapcraft/current/lib/python3.5/site-packages/snapcraft/internal/pluginhandler/__init__.py", line 394, in mark_done
4204     f.write(yaml_utils.dump(state))
4205   File "/snap/snapcraft/current/lib/python3.5/site-packages/snapcraft/yaml_utils.py", line 38, in dump
4206     data, stream, _SafeOrderedDumper, default_flow_style=False, allow_unicode=True
4207   File "/snap/snapcraft/current/lib/python3.5/site-packages/yaml/__init__.py", line 200, in dump
4208     return dump_all([data], stream, Dumper=Dumper, **kwds)
4209   File "/snap/snapcraft/current/lib/python3.5/site-packages/yaml/__init__.py", line 188, in dump_all
4210     dumper.represent(data)
4211   File "/snap/snapcraft/current/lib/python3.5/site-packages/yaml/representer.py", line 27, in represent
4212     self.serialize(node)
4213   File "ext/_yaml.pyx", line 1348, in _yaml.CEmitter.serialize
4214   File "ext/_yaml.pyx", line 1510, in _yaml.CEmitter._serialize_node
4215   File "ext/_yaml.pyx", line 1509, in _yaml.CEmitter._serialize_node
4216   File "ext/_yaml.pyx", line 1428, in _yaml.CEmitter._serialize_node
4217 UnicodeEncodeError: 'utf-8' codec can't encode character '\udcc5' in position 62: surrogates not allowed
4218 You can find the traceback in file '/tmp/tmpf6fg3bnh/trace.txt'.