Update! Please see this bug report: https://bugs.launchpad.net/snapcraft/+bug/1906660
I’m trying to debug an issue on my local machine and CI for the Node package electron-installer-snap
which uses the snapcraft
tool under the hood to build snap
packages.
That context aside, I’m needing to run the snapcraft
command manually to try and see what error messages are happening.
When I run (without any content redirection):
$ snapcraft snap --target-arch=amd64 --output=/tmp/electron-installer-snap--17940-YGm5oN0GL92C/footest_0.0.1_amd64.snap
I can see the error message clear and fine, which is what I was after, so that I can further work on the issue:
Setting target machine to 'amd64'
Failed to get part information: Cannot find the definition for part 'desktop-gtk3', required by part 'footest'.
Remote parts are not supported with bases, so make sure that this part is defined in the `snapcraft.yaml`.
When I try and redirect output with (appending > stdout.txt
):
$ snapcraft snap --target-arch=amd64 --output=/tmp/electron-installer-snap--17940-YGm5oN0GL92C/footest_0.0.1_amd64.snap > stdout.txt
I get the following:
Error in sys.excepthook:
Traceback (most recent call last):
File "/snap/snapcraft/5756/lib/python3.6/site-packages/snapcraft/cli/_errors.py", line 270, in exception_handler
_process_outer_exception(exc_info, debug)
File "/snap/snapcraft/5756/lib/python3.6/site-packages/snapcraft/cli/_errors.py", line 207, in _process_outer_exception
click.echo(_MSG_TRACEBACK_PRINT)
File "/snap/snapcraft/5756/lib/python3.6/site-packages/click/utils.py", line 273, in echo
file.flush()
PermissionError: [Errno 13] Permission denied
Original exception was:
Traceback (most recent call last):
File "/snap/snapcraft/5756/bin/snapcraft", line 33, in <module>
sys.exit(load_entry_point('snapcraft==4.4.2', 'console_scripts', 'snapcraft')())
File "/snap/snapcraft/5756/lib/python3.6/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/snap/snapcraft/5756/lib/python3.6/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/snap/snapcraft/5756/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/snap/snapcraft/5756/lib/python3.6/site-packages/snapcraft/cli/_command.py", line 89, in invoke
return super().invoke(ctx)
File "/snap/snapcraft/5756/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/snap/snapcraft/5756/lib/python3.6/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/snap/snapcraft/5756/lib/python3.6/site-packages/snapcraft/cli/lifecycle.py", line 382, in snap
_execute(steps.PRIME, parts=tuple(), pack_project=True, output=output, **kwargs)
File "/snap/snapcraft/5756/lib/python3.6/site-packages/snapcraft/cli/lifecycle.py", line 83, in _execute
"Ignoring '--target-arch' flag. This flag requires --destructive-mode and is unsupported with Multipass and LXD build providers."
File "/snap/snapcraft/5756/lib/python3.6/site-packages/snapcraft/cli/echo.py", line 63, in warning
click.echo("\033[1;33m{}\033[0m".format(msg))
File "/snap/snapcraft/5756/lib/python3.6/site-packages/click/utils.py", line 273, in echo
file.flush()
PermissionError: [Errno 13] Permission denied
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
PermissionError: [Errno 13] Permission denied
If I run (appending | cat > stdout.txt
):
$ snapcraft snap --target-arch=amd64 --output=/tmp/electron-installer-snap--17940-YGm5oN0GL92C/footest_0.0.1_amd64.snap | cat > stdout.txt
This appears to work fine.
For tools that use or spawn snapcraft
under the hood, it seems impossible to retrieve any error messages when snapcraft fails to run.
In the error output from electron-installer-snap
, you can see that both stdout
and stderr
are blank:
Error (ExitCodeError) {
args: [
'snap',
'--output=/tmp/electron-installer-snap--17940-YGm5oN0GL92C/footest_0.0.1_amd64.snap',
],
cmd: '/snap/bin/snapcraft',
code: 120,
stderr: '',
stdout: '',
message: `Command failed with a non-zero return code (120):␊
/snap/bin/snapcraft snap --output=/tmp/electron-installer-snap--17940-YGm5oN0GL92C/footest_0.0.1_amd64.snap`,
}