snapcraft fails if desktop file included "ascii" cannot decode byte

Bug #1662456 reported by Light on Flux
20
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Snapcraft
Fix Released
High
Leo Arias

Bug Description

When including the project .desktop file building the snap fails:

'ascii' codec can't decode byte 0xc3 in position 51: ordinal not in range(128)

Generated desktop file is attached. As well as the snapcraft file.

Tags: isv
Revision history for this message
Light on Flux (lightonflux) wrote :
Revision history for this message
Light on Flux (lightonflux) wrote :
Revision history for this message
Light on Flux (lightonflux) wrote :

This problem only appears when building on 16.04 but not on 16.10.

Revision history for this message
Light on Flux (lightonflux) wrote :

And it does not appear when you manually compile the program on 16.04.

Revision history for this message
Martin Wimpress  (flexiondotorg) wrote :

I confirm this issue.

The 'apps' portion of my my snapcraft.yaml looks something like this.

    apps:
      something-test:
        command: desktop-launch $SNAP/usr/lib/something/something
        desktop: usr/share/applications/tld.something.app.desktop
        plugs: [browser-support, gsettings, home, mount-observe, network, opengl, pulseaudio, unity7, x11]

The referenced .desktop file includes UFT-8 translated Comment fields for:

    Comment[ar]=
    Comment[bg]=
    Comment[ja]=
    Comment[ru]=
    Comment[sr]=
    Comment[zh]=

tags: added: isv
Revision history for this message
Leo Arias (elopio) wrote :

Thanks for the report!

Changed in snapcraft:
status: New → Confirmed
importance: Undecided → High
Revision history for this message
Martin Wimpress  (flexiondotorg) wrote :

Some additional testing:

  * Running `snapcraft cleanbuild` on 16.10 results in the same 'ascii' codec can't decode byte error.
  * Running `snapcraft` on 16.10 completed successfully.

Changed in snapcraft:
status: Confirmed → Triaged
milestone: none → 2.28
Changed in snapcraft:
milestone: 2.28 → none
Revision history for this message
Leo Arias (elopio) wrote :

I worked this around by setting the env var LC_ALL=en_US.UTF-8 and running locale-gen en_US.UTF-8. We can do this in our lxd container during cleanbuild for sure.

For cases out of cleanbuild, like running snapcraft in docker, a failure might be more appropriate, because we probably shouldn't play with people's env.

Revision history for this message
Light on Flux (lightonflux) wrote : Re: [Bug 1662456] Re: snapcraft fails if desktop file included "ascii" cannot decode byte

Am 26.03.2017 um 01:16 schrieb Leo Arias:
> I worked this around by setting the env var LC_ALL=en_US.UTF-8 and
> running locale-gen en_US.UTF-8. We can do this in our lxd container
> during cleanbuild for sure.
>
> For cases out of cleanbuild, like running snapcraft in docker, a failure
> might be more appropriate, because we probably shouldn't play with
> people's env.
>

Did it work with LANG=C?

In LXD upstream the issue was fixed. New (2.9 and later) versions should
automatically set LANG=C when using "lxc exec":

https://github.com/lxc/lxd/issues/2830

Revision history for this message
Leo Arias (elopio) wrote :

Hello affected people!

Here's a simple fix for cleanbuild: https://github.com/snapcore/snapcraft/pull/1304

Can you please tell me if this happened to you on a normal build without containers too? And if so, how did you end up with a system that only supports ascii?

Changed in snapcraft:
assignee: nobody → Leo Arias (elopio)
status: Triaged → In Progress
milestone: none → 2.30
Revision history for this message
Leo Arias (elopio) wrote :

Here's another small change, to make sure that the desktop file we read and write is encoded as utf8:
https://github.com/snapcore/snapcraft/pull/1309

Changed in snapcraft:
status: In Progress → Fix Committed
Revision history for this message
Martin Wimpress  (flexiondotorg) wrote :
Download full text (3.5 KiB)

Didn't work for me sadly.

$ snap info snapcraft

name: snapcraft
summary: "easily create snaps"
publisher: canonical
contact: <email address hidden>
description: |
  Snapcraft aims to make upstream developers' lives easier and as such is not a
  single toolset, but instead is a collection of tools that enable the natural
  workflow of an upstream to be extended with a simple release step into Snappy
  enabled system.
commands:
  - snapcraft
tracking: stable/new-cli
installed: 2.29.1+git51.3e5e2d8 (154) 53MB classic
refreshed: 2017-05-16 20:30:30 +0100 BST
channels:
  latest/beta: 2.29.1 (99) 53MB classic
  latest/edge: 2.29.1+git38.6387808 (168) 53MB classic

Here is the Traceback:

'ascii' codec can't decode byte 0xc3 in position 463: ordinal not in range(128)
Stopping local:snapcraft-nonnoumenally-insentient-despina
Traceback (most recent call last):
  File "/snap/snapcraft/154/bin/snapcraft", line 32, in <module>
    obj=dict(project=snapcraft.ProjectOptions()))
  File "/snap/snapcraft/154/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/snap/snapcraft/154/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/snap/snapcraft/154/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/snap/snapcraft/154/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/snap/snapcraft/154/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/snap/snapcraft/154/lib/python3.6/site-packages/snapcraft/cli/lifecycle.py", line 202, in cleanbuild
    lifecycle.cleanbuild(project_options, remote)
  File "/snap/snapcraft/154/lib/python3.6/site-packages/snapcraft/internal/lifecycle.py", line 343, in cleanbuild
    metadata=config.get_metadata(), remote=remote).execute()
  File "/snap/snapcraft/154/lib/python3.6/site-packages/snapcraft/internal/lxd.py", line 125, in execute
    raise e
  File "/snap/snapcraft/154/lib/python3.6/site-packages/snapcraft/internal/lxd.py", line 119, in execute
    self._container_run(command)
  File "/snap/snapcraft/154/lib/python3.6/site-packages/snapcraft/internal/lxd.py", line 86, in _container_run
    'HOME=/{}'.format(self._project_folder), '--'] + cmd)
  File "/snap/snapcraft/154/usr/lib/python3.6/subprocess.py", line 291, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['lxc', 'exec', 'local:snapcraft-nonnoumenally-insentient-despina', '--env', 'HOME=/build_vscode', '--', 'snapcraft', 'snap', '--output', 'vscode_1.12.2-1494422229_amd64.snap']' returned non-zero exit status 1.

And this is the .desktop file:

[Desktop Entry]
Name=Visual Studio Code
Comment=Code Editing. Redefined.
GenericName=Text Editor
Exec=/usr/share/code/code --unity-launch %U
Icon=/usr/share/pixmaps/code.png
Type=Application
StartupNotify=true
StartupWMClass=Code
Categories=Utility;TextEditor;Development;IDE;
MimeTyp...

Read more...

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

oh, cleanbuild and desktop files would require us to first get said snapcraft SRUed.

Revision history for this message
Leo Arias (elopio) wrote :

we should probably install squashfuse and the snapcraft stable snap, instead of the deb.

Changed in snapcraft:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.