Program can't find files included in Snap


#1

Hello! I have created Snap package of Midnight Commander. Program starts, but don’t find files included in package. As a result, skins and localization don’t work.

My snapcraft.yaml:

name: mc
version: '4.8.22'
summary: GNU Midnight Commander is a visual file manager, licensed under GPL
description: |
  GNU Midnight Commander is a visual file manager, licensed under GNU General Public License and therefore qualifies as Free Software. It's a feature rich full-screen text mode application that allows you to copy, move and delete files and whole directory trees, search for files and run commands in the subshell. Internal viewer and editor are included.

  Midnight Commander is based on versatile text interfaces, such as Ncurses or S-Lang, which allows it to work on a regular console, inside an X Window terminal, over SSH connections and all kinds of remote shells.
passthrough:
  title: Midnight Commander
  license: GPL-3.0+
icon: additional/share/icons/hicolor/64x64/apps/MidnightCommander.png

grade: stable
confinement: devmode

parts:
  mc:
    plugin: autotools
    source: https://github.com/MidnightCommander/mc/archive/4.8.22.tar.gz
    build-packages:
      - libc6
      - gcc
      - make
      - autoconf
      - automake
      - libtool
      - libglib2.0-0
      - libpcre3
      - libslang2-dev
      - gettext
      - cvs
      - libssh2-1
      - libaspell15
  additional: # Shortcuts and icons
    plugin: dump
    source: additional

apps:
  mc:
    command: mc
    desktop: share/applications/mc.desktop
    plugs: [home, mount-observe, network-control]
  mcedit:
    command: mcedit
    desktop: share/applications/mcedit.desktop
  mcdiff:
    command: mcdiff
  mcview:
    command: mcview

MC gives errors:

sfs_init(): Warning: file /etc/mc/sfs.ini not found
Warning: cannot open /libexec/mc/extfs.d directory
Warning: cannot load codepages list

Log from snappy-debug:

INFO: following '/var/log/syslog'. If have dropped messages, use:
INFO: $ sudo journalctl --output=short --follow --all | sudo snappy-debug
sysctl: permission denied on key 'kernel.printk_ratelimit'
DEBUG: syslog seems to work (found syslog mark)
= AppArmor =
Time: Feb 10 19:22:11
Log: apparmor="ALLOWED" operation="open" profile="snap.mc.mc" name="/etc/mc/sfs.ini" pid=9062 comm="mc" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
File: /etc/mc/sfs.ini (read)
Suggestion:
* adjust program to read necessary files from $SNAP, $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON

= AppArmor =
Time: Feb 10 19:22:12
Log: apparmor="ALLOWED" operation="open" profile="snap.mc.mc" name="/etc/mc/mc.default.keymap" pid=9062 comm="mc" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
File: /etc/mc/mc.default.keymap (read)
Suggestion:
* adjust program to read necessary files from $SNAP, $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON

= AppArmor =
Time: Feb 10 19:22:14
Log: apparmor="ALLOWED" operation="open" profile="snap.mc.mc" name="/etc/mc/filehighlight.ini" pid=9062 comm="mc" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
File: /etc/mc/filehighlight.ini (read)
Suggestion:
* adjust program to read necessary files from $SNAP, $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON

= AppArmor =
Time: Feb 10 19:22:14
Log: apparmor="ALLOWED" operation="open" profile="snap.mc.mc" name="/proc/9062/mountinfo" pid=9062 comm="mc" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000
File: /proc/9062/mountinfo (read)
Suggestions:
* adjust program to not access '@{PROC}/@{pid}/mountinfo'
* add 'mount-observe' to 'plugs'

= AppArmor =
Time: Feb 10 19:34:20
Log: apparmor="ALLOWED" operation="open" profile="snap.mc.mc" name="/etc/mc/sfs.ini" pid=9361 comm="mc" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
File: /etc/mc/sfs.ini (read)
Suggestion:
* adjust program to read necessary files from $SNAP, $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON

= AppArmor =
Time: Feb 10 19:34:20
Log: apparmor="ALLOWED" operation="open" profile="snap.mc.mc" name="/etc/mc/mc.default.keymap" pid=9361 comm="mc" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
File: /etc/mc/mc.default.keymap (read)
Suggestion:
* adjust program to read necessary files from $SNAP, $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON

= AppArmor =
Time: Feb 10 19:34:42
Log: apparmor="ALLOWED" operation="open" profile="snap.mc.mc" name="/etc/mc/filehighlight.ini" pid=9361 comm="mc" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
File: /etc/mc/filehighlight.ini (read)
Suggestion:
* adjust program to read necessary files from $SNAP, $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON

= AppArmor =
Time: Feb 10 19:34:42
Log: apparmor="ALLOWED" operation="open" profile="snap.mc.mc" name="/proc/9361/mountinfo" pid=9361 comm="mc" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000
File: /proc/9361/mountinfo (read)
Suggestions:
* adjust program to not access '@{PROC}/@{pid}/mountinfo'
* add 'mount-observe' to 'plugs'

#2

Upon startup the application will look for certain files and directories with a fixed path, for example, /usr/share/foo. In snap world however those are always variable, typically under $SNAP/usr/share/foo where $SNAP expands to /snap/$SNAP_NAME/$SNAP_REVISION e.g. /snap/foo/42.

As one way to address this issue you can look at snap layouts: https://docs.snapcraft.io/snap-layouts/7207


#3

Thanks, but I solved the problem with hack from GNOME Calculator:

parts:
  mc:
    plugin: autotools
    ...
    configflags: [ --prefix=/snap/mc/current/usr ]
    organize:
      snap/mc/current/usr: usr