Skip to content

File picker with classic Snap  #19818

Closed
Closed

Description

@zarubond

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

I have the Electron in Snap package with classic confinement. When I create an input type file and select a file which has non-ASCII characters inside its name, the whole Electron crashes.

  • Electron Version:
    5.0.9, 6.0.2
  • Operating System:
    Ubuntu 18.04
  • Last Known Working Electron version:
    3.1.12

Expected Behavior

Electron should be able to pick a file with any name.

Actual Behavior

Electron crashes if non-ASCII file is selected

To Reproduce

Clone there repository on Linux
https://github.com/zarubond/electron-quick-start/tree/snap_filepicker
Then run/install it
npm install
npm run dist
cd dist
sudo snap install --dangerous --classic electron-quick-start_1.0.0_amd64.snap
Now start the installed application and pick a file with non-ASCII name. ("pőúáöüűé.dat" for example)

Screenshots

Additional Information

Activity

  1. popey commented on Aug 19, 2019

    @popey

    It looks like something in $SNAP/desktop-common.sh is causing this while it's a classic snap. When the sample above is built as a strict snap, it does not exhibit this issue.

    However, as a classic snap, the environment setup by the desktop-init.sh, desktop-common.sh and desktop-gnome-specification.sh scripts appear to cause a conflict between the GTK libraries / environment inside the $SNAP and that outside on the host.

    To prove, build the snap, but rather than install it, unpack it and use snap try to "install" the directory as a snap.

    Remove the snap

    $ snap remove electron-quick-start

    Unsquash the snap

    $ unsquashfs electron-quick-start_1.0.0_amd64.snap

    "Install" the snap from the directory

    $ snap install ./squashfs-root/ --classic

    Observe the command chain

    $ cat squashfs-root/command.sh
    #!/bin/bash -e
    exec "$SNAP/desktop-init.sh" "$SNAP/desktop-common.sh" "$SNAP/desktop-gnome-specific.sh" "$SNAP/electron-quick-start" "$@" --no-sandbox
    

    Running the application with snap run electron-quick-start and choosing a file with non-ASCII name fails as expected.

    Remove launcher script to test

    Edit ./squashfs-root/command.sh to remove "$SNAP/desktop-common.sh" and "$SNAP/desktop-gnome-specific.sh" from the command chain.

    $ cat squashfs-root/command.sh 
    #!/bin/bash -e
    exec "$SNAP/desktop-init.sh" "$SNAP/electron-quick-start" "$@" --no-sandbox
    

    Re-run the snap (no need to remove/reinstall or rebuild as with snap try you're editing the files "inside" the snap live). Now the snap works fine, as expected.

    Not a solution, but it does point the finger at the scripts used to setup the environment.

  2. sergiusens commented on Aug 20, 2019

    @sergiusens

    When using classic, most of the scripted logic in these parts should not be used as they will clash with what is on the system

  3. cjp256 commented on Aug 20, 2019

    @cjp256
    Contributor

    As @sergiusens pointed out, these scripts weren't meant to be used with the classic builds.

    FWICT, what's happening here is LOCPATH is being set to /usr/share/locale. Note the comment above that suggests all locales needing to be installed:
    https://github.com/develar/app-builder/blob/master/pkg/package-format/snap/desktop-scripts/desktop-common.sh#L150

    I reproduce the behavior of this ticket if I do not have locales-all installed. Once I install it, behavior is as expected.

  4. cjp256 commented on Aug 21, 2019

    @cjp256
    Contributor

    LOCPATH causes the system to not use the locale-archive, and instead search out the data files (in my case: /usr/lib/locale/en_US.utf8/LC_* - which is only present if locales-all is installed and the archive is not used.

    Otherwise, outputpath is the name of a locale and the compiled
              locale data is added to the archive file /usr/lib/locale/locale-
              archive.  A locale archive is a memory-mapped file which contains
              all the system-provided locales; it is used by all localized
              programs when the environment variable LOCPATH is not set.
    

    from http://man7.org/linux/man-pages/man1/localedef.1.html

  5. cjp256 commented on Aug 21, 2019

    @cjp256
    Contributor

    For reference, I do believe the following launcher may be more appropriate for electron-based classic snaps:
    https://github.com/microsoft/vscode/blob/master/resources/linux/snap/electron-launch

  6. added
    status/confirmed
    and removed
    status/confirmed
    on Aug 30, 2019
  7. ckerr commented on Aug 30, 2019

    @ckerr
    Member

    From the Canonical folks' discussion above between @popey, @sergiusens, and @cjp256, it sounds like this issue should be closed in this tracker as a Snappy issue rather than an Electron one. Nice triage work, Canonical.

  8. cjp256 commented on Aug 31, 2019

    @cjp256
    Contributor

    @ckerr It's a combination of electron-builder and its usage of app-builder(-lib), and the process used to generate the pre-built template tarball found @ https://github.com/electron-userland/electron-builder-binaries/releases/tag/snap-template-4.0-2 . The pre-built template tarball appears to be built for use with strict snaps, yet is being used with classic snaps as is done in this case.

    Perhaps @develar can point us at the right direction as to where exactly this would be ideally filed and how best appropriate to handle this? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions