150

I'm not particularly fond of apps cluttering my $HOME directory with their own files or directories. It's rarely a problem, because most apps have the courtesy to hide their data by prefixing it with a dot or conforming to the ~/.config standard. But not snap.

Q1: Have I misunderstood this directory? Is ~/snap really a directory which I'm supposed to enter and access on a daily basis on a par with ~/downloads, ~/pictures, ~/work, etc?

Q2: In any case: Can I rename it to e.g. ~/.snap? I can't find anything like /etc/snap, /etc/default/snap, or ~/.config/snap to tweak things. I tried export SNAP_USER_DATA=$HOME/.snap but it didn't work.

  • 23
    It can't. But I don't have just this one file in my home dir, I have quite a lot. And many a little makes a mickle. Furthermore I have configured my system so that not $HOME/Desktop but $HOME directly is shown on my desktop because it makes more sense to me this way, but this also means that unwanted directories and files here will be even more visible and annoying. And then there's this whole thing about apps should hide their configuration files. – Stephan Henningsen Mar 31 '18 at 22:08
  • 29
    Or thinking about it this way: Suddenly someone walks in, puts a box on your table, and walks out again without a word. Don't you think that at some point you'd find that box got in you way and would want to remove it? =) I for sure like to decide what goes on my own table, and similarly what files are (visible) in my $HOME. – Stephan Henningsen Mar 31 '18 at 22:20
  • 14
    Trololo? Run this in your home folder and you'll see what happens if every program just created one single folder in your home dir: for f in .*; do g="${f#.}"; echo "How can a single file clutter your home folder? It's just ${g}." ; echo ln -sv "$f" "${g}_"; done

    This is actually harmless to run, but you should remove the last echo there and I think you'll "buy my line of thought".

    – Stephan Henningsen Apr 05 '18 at 07:49
  • 3
    Right... So half of the conversation has been deleted which makes me look rather skizofrenic =). But for the record, the initial and follow-up comment sounded something like "How can one file clutter your home dir? [...] I still don't buy your line of thought". – Stephan Henningsen Mar 07 '20 at 22:48
  • 1
    They are currently claiming a "workaround" of "making the folder 'hidden'" (https://cialu.net/how-to-move-snap-folder-away-from-home-location-in-linux/) but the "workaround" is not a workaround, and doesn't make the folder hidden, it just removes it from displays in graphic file managers but of course the directory is still there, still called "~/snap", and still brazenly visible in the home directory to CLI. – NeilG Jul 19 '21 at 02:40
  • 1
    It's the same workaround that had been mentioned in a couple of the answers here. And like you concluded yourself, it's not a very good one. – Stephan Henningsen Jul 20 '21 at 18:37

6 Answers6

160

So..

A1: No; ~/snap is not supposed to be accessed manually on a daily basis; it's a settings directory.

A2: No; ~/snap cannot be changed; it's cluttering your home dir by design.

However there is already a bug report on this issue, but it's currently only prioritized as wishlist. If you're affected by this bug (and you are if you have a ~/snap =) then let the kind developers know, and encourage them to fix the bug by raising its significance:

  1. Go to the bug report
  2. Login to Launchpad (top right corner).
  3. Click This bug affects N people. Does this bug affect you? (near top left)
  4. Click Yes, this bug affects me

In the meantime do like @Rinzwind suggests and simply hide the directory from Nautilus by typing this in a shell:

echo snap >> ~/.hidden

Alternative get completely rid of snap by downright uninstalling everything related snap, as described here.

  • 36
    Done. Thanks for pointing out that bug report. Believe me, if a snap directory appears in my $HOME when I install a snap, I can confidently say that I won't ever use this technology. If, as I suspect, this becomes a concrete piece of the Ubuntu landscape, I'll have to rethink my decades-long commitment to the platform. Crazy decision. – Scaine Aug 29 '17 at 19:06
  • 1
    Just voted as well - seems like something might be happening. I'll repeat from Stephan's comment in the bug report: "It's 2017, come on." – Larpon Oct 05 '17 at 08:16
  • 20
    It's 2019, and still no progress on this. Come on! Purging snap right now. – Murphy Apr 09 '19 at 08:33
  • 11
    it's the arrogance of it that's most irritating. Uninstalling. – Dodgie Dec 06 '19 at 00:03
  • 8
    Exactly! "So what if we pooped in your homedir? Deal with it!". Which brings us here. – Stephan Henningsen Dec 06 '19 at 08:36
  • 8
    I actually completely removed snap only because of the described issue. I used it to install Google Chrome, but f*ck that if this isn't fixed... – 0ne_Up Aug 22 '20 at 11:01
  • 2
    This also works well with KDE / Kubuntu's Dolphin file manager. Thanks! – may Apr 12 '21 at 20:26
  • 2
    Something is happening: https://github.com/snapcore/snapd/pull/10836 – Martin Nov 23 '21 at 23:39
31

Q1: Have I misunderstood this directory? Is ~/snap really a directory which I'm supposed to enter and access on a daily basis on a par with ~/downloads, ~/work, ~/tmp, etc?

It is a regular directory but is not really meant for user access. It is managed by the snapd utility. It seems likely it will be renamed to ~/.snap at some point. Or less likely to ~/.local/share/snap.

Q2: In any case: How do I hide it?

When it is renamed it will be hidden automatically.

To hide from the desktop shell for now, create a text file called ~/.hidden and put the word "snap" in it. This will hide the "~/snap" folder from Nautilus.

To hide from the command line for now, alias ls to ls -Isnap. Now "snap" will be ignored when ls-ing.

lofidevops
  • 20,924
Rinzwind
  • 299,756
  • 4
    "alias ls to ls -Isnap" Note that it will hide "snap" wherever you run ls, not only in the $HOME directory. The real solution belongs to snap. – jrouquie Sep 29 '18 at 10:47
  • This solution does not show show the snap directory, but it also ignores the color preferences I have saved for different file types, i.e. there is no way to visually distinguish between files and directories. Any tips? – Display name Apr 08 '19 at 14:35
  • 1
    @NicholasCousar run alias ls before setting the new alias, this will show you the existing alias (probably alias ls='ls --color=auto'). You can then add the option at the end, alias ls='ls --color=auto -Isnap' – Suzanne Soy Feb 03 '21 at 02:37
  • Thanks for the ~/.hidden solution, good enough for me. – Yimin Rong Aug 01 '23 at 16:27
5

This is currently possible as an experimental feature flag.

$ sudo snap set system experimental.hidden-snap-folder=true

The flag can also be disabled by running.

$ sudo snap unset system experimental.hidden-snap-folder
ogtega
  • 51
  • 2
    Interesting! I don't know what to think of this. I mean, the mere fact than this has taken 5 years to implement and it still considered experimental feature suggest that this is a hack. It will probably just be ~/.snap instead of ~/.config/share/snap. And maybe that's fine, I don't know anymore; I'm mad at snap and got tired fighting it so I switched to Arch. No matter what: Congratz on your first post. I's nice and complete! =) – Stephan Henningsen Oct 19 '22 at 05:38
5

All snap applications themselves (in case they are installed) are located in the /snap directory.
/home/user/snap contains your personal settings of those snaps (in case they are installed).
The /home/user/snap folder was created once when you've installed the first snap package.

In case you don't have snap applications installed, you can delete the /home/user/snap folder.
If you install and use new snap applications, the folder will be re-created - this is done by design.
As snapd is "work in progress" - maybe another default directory can be selected in the future.

cl-netbox
  • 31,163
  • 7
  • 94
  • 131
  • 4
    If you desire a configuration option for this, I'd recommend filing a bug against snapd itself, here:- https://bugs.launchpad.net/snappy/+bugs – popey Feb 12 '17 at 16:43
  • 1
    @popey Way ahead of you =) I even found out someone already filed a bug report. I'm answering my own question with instructions on how to encourage the developers to fix it. – Stephan Henningsen Feb 12 '17 at 17:14
-2

I think I actually have a solution for this! Well kinda. There's a Nautilus extension called "Nautilus Hide" that will hide files and folders without changing their name. It basically writes the name of the folder to a file that Nautilus uses to see if a folder should be hidden or not.

Works like a charm!

https://github.com/brunonova/nautilus-hide

  • 2
    I'm unsure what to make of this. While this does answer half of the question's title, it doesn't address any of the two questions in the body. You describe another work-around to hide a directory in Nautilus though (what I see is) a user-friendly plug-in for users who aren't comfortable with shell one-liners (ie. echo snap >> ~/.hidden) ... but do know their way around git, cmake and sudo make install. I guess this adds something new to the table. – Stephan Henningsen Aug 16 '18 at 06:31
  • Sometimes you want to hide and unhide a folder without having to pull up your CLI yah know? It's faster to right click on something and say hide than it is to open a program and type out a command. At least for me. – Aslan French Aug 16 '18 at 22:07
  • 1
    You say "sometimes", but this question is all about one single directory. And you still have to "pull up the CLI" to do the work you propose, and you're need to install git to pull it, and the whole build system to compile it, and finally run sudo to install it. This is far more complicated. At least for me. – Stephan Henningsen Aug 17 '18 at 06:15
  • 1
    Cool, Don't really see why it's worth a downvote though. Seems to not fall within the community guidelines. My solution isn't wrong and may be considered useful to someone else who views this page. – Aslan French Aug 20 '18 at 21:06
  • Your solution to add snap to ~/.hidden was already explained in two existing answers; only difference is that your approach is way more complicated. I don't find that useful, I wouldn't recommend this approach to anyone, hence -1 to usefulness. – Stephan Henningsen Aug 29 '18 at 05:41
-2

To hide from the command line for now, alias ls to ls -I snap --color=tty

This can show the color preference.