SNAP_REAL_HOME is kinda buggy

I’m snapping a recent app, which is to save the desktop-environment config files. It needs the access to the home folder. But, when I set the HOME: "$SNAP_REAL_HOME", the Desktop and Public folders will get changed and unusable. I guess it makes some changes in the xdg_usr_dirs config file. Is there any fix to this bug? What can be done to fix?

1 Like

Hi soumyaDghosh,

Would you please the steps to reproduce this issue?

Install any snap which has


i.e the HOME is set to $SNAP_REAL_HOME in the environment section.

  1. Open the snap.
  2. Then check the file manager.
  3. You’ll see something like this;

I tested this with my own snaps which used SNAP_REAL_HOME, and recently tested it with the dosbox-staging snap by @popey.

Are you launching your app through sudo? if you are, then that will be why the permissions get broken.

Nope, not at all. Why should I even do so? There is no need. Try with the snap I named or any snap that has $SNAP_REAL_HOME.

Even if the HOME is set to /home/$USER, the problem still persists.

Any progress on this issue?


This is what I got today by opening dosbox-staging in an Ubuntu live environment

Folders, which had nothing in them, got changed. Their permissions I guess got changed. @lucyllewy kindly check this issue.

It looks like they’ve been replaced with symbolic links pointing elsewhere. As a way of trying to understand what’s going wrong so the devs can fix it, can you right click on one and open the properties window to see where it is pointing. A screenshot of the window showing the location might be useful.

Every thing seems to be fine. But it’s for some reason getting linked. Clicking on the link target is opening a new window of nautilus and highlighting the link of the DESKTOP folder again.

NB: It only happens when any of the preset folders are empty.

I’m thinking this is a desktop-extension issue then. Specifically in the launch script that wraps the app inside most desktop snap packages (when the packager configures it to do so, but this is standard practice.) I’m looping in @kenvandine to assign to someone on the desktop team to have a look at this.

1 Like

I beg to differ, because I found the issue with many extensions flutter-master, flutter-stable, gnome, gnome-3-38(this snap I mentioned earlier uses it).

Hi soumyaDghosh,

I do think something is odd/wrong here, perhaps a bug. Is our app classic-confined or non-classic snap? I presume you have the home interface configured?

If you do not mind, I want to make sure I understand your use case a correctly. $HOME by default points to /home/_user_name_/snap/_snap_name_/_snap_revision_ and $SNAP_REAL_HOME to /home/_user_name_. Why is it required to change $HOME to $SNAP_REAL_HOME in order to “save the desktop-environment config files”?

Answering one by one.

dosbox-staging and other snaps that I tested are snaps with grade: strict Means they are non-classic

Didn’t understand this question correctly? Can you make me that out?

Yes this is the case for non-classic snaps.

I have two main reasons for this,

  1. Apps where the user needs to pick some file from the file-chooser, if the HOME folder takes them to somewhere else, then it’ll be very confusing for them that to access files saved in the /home/$USER, they need to click on their username on the top bar of the file manager.
  2. I am recently snapping an app which saves the config file of my current desktop as a backup. And when needed, they can restore them. The app is savedesktop I am talking about. It needs the correct home path for that purpose. Also, currently the portal is not working with snaps, so, this is the only alternative left, which needs to bug free for now. This is the forum post I’m talking about.

My current

name: savedesktop # you probably want to 'snapcraft register <name>'
base: core22 # the base snap is the execution environment for this snap
version: '1.8.1' # just for humans, typically '1.2+git' or '1.3.2'
summary: Single-line elevator pitch for your amazing snap # 79 char long summary
description: |
  This is my-snap's description. You have a paragraph or two to tell the
  most important story about your snap. Keep it under 100 words though,
  we live in tweetspace and your description wants to look good in the snap

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots
    interface: dbus
    bus: session
    name: org.gnome.SessionManager
    interface: dbus
    bus: session
    name: org.xfce.SessionManager
    # See 'snapcraft plugins'
    plugin: dump
    override-pull: |
      craftctl default
      sed -i 's|Icon=io.github.vikdevelop.SaveDesktop|Icon=usr/share/icons/hicolor/128x128/apps/io.github.vikdevelop.SaveDesktop.png|' flatpak/io.github.vikdevelop.SaveDesktop.desktop
      sed -i 's|locale = open(f"/app/translations/{lang}")|locale = open(f"/snap/savedesktop/current/usr/translations/{lang}")|' src/
      sed -i 's|~/|/home/$USER/|' -i src/
      sed -i 's|~/.config|/home/$USER|' -i src/
      sed -i 's|/app/|/snap/savedesktop/current/usr/|'
    override-build: |
      craftctl default
      install -Dm755 -t ${CRAFT_PART_INSTALL}/usr/bin/
      install -Dm755 -t ${CRAFT_PART_INSTALL}/usr/ src/
      install -D -t ${CRAFT_PART_INSTALL}/usr/share/applications flatpak/io.github.vikdevelop.SaveDesktop.desktop
      install -D -t ${CRAFT_PART_INSTALL}/usr/share/icons/hicolor/128x128/apps flatpak/icons/io.github.vikdevelop.SaveDesktop.png
      install -D -t ${CRAFT_PART_INSTALL}/usr/share/icons/hicolor/128x128/apps flatpak/symbolic-icons/exclamation_mark.png
      install -D -t ${CRAFT_PART_INSTALL}/usr/share/metainfo flatpak/io.github.vikdevelop.SaveDesktop.metainfo.xml
      cp -R translations ${CRAFT_PART_INSTALL}/usr/
    command: usr/bin/
    desktop: usr/share/applications/io.github.vikdevelop.SaveDesktop.desktop
    common-id: io.github.vikdevelop
    extensions: [ gnome ]
    plugs: [ home ]

file for savedesktop

Any update on this issue @ernestl

Would the homeishome wrapper helpful for this?

The current code is small, so, as per I have checked, this app directly calls python subprocess to save files in ~/ or copy from those config files.

Also, there are calls by it done to the {path.home}/ I need the call done to home itself, not to something assigned as home. The script fixes the assign, and the app follows it and searches for config files under SNAP_USER_DATA