How can I change or hide the ~/snap directory?

46,870

Solution 1

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.

Solution 2

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.

Solution 3

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.

Share:
46,870

Related videos on Youtube

Stephan Henningsen
Author by

Stephan Henningsen

Hacker.

Updated on September 18, 2022

Comments

  • Stephan Henningsen
    Stephan Henningsen over 1 year

    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 move it 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.

    • Stephan Henningsen
      Stephan Henningsen about 6 years
      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
      Stephan Henningsen about 6 years
      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
      Stephan Henningsen about 6 years
      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".
    • Mubbasher Khaliq
      Mubbasher Khaliq over 5 years
      Internet people love to tell you how your question is wrong rather than just answering your question, don't they?
    • Stephan Henningsen
      Stephan Henningsen about 4 years
      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".
    • TheMechanic
      TheMechanic over 3 years
      I can't believe it's been almost 4 years and this is still a thing. SNAP, GTFO MY HOME DIR
    • NeilG
      NeilG almost 3 years
      They are currently claiming a "workaround" of "making the folder 'hidden'" (cialu.net/…) 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.
    • Stephan Henningsen
      Stephan Henningsen almost 3 years
      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.
  • undsoft
    undsoft over 7 years
    If you desire a configuration option for this, I'd recommend filing a bug against snapd itself, here:- bugs.launchpad.net/snappy/+bugs
  • Stephan Henningsen
    Stephan Henningsen over 7 years
    @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.
  • Scaine
    Scaine over 6 years
    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.
  • Larpon
    Larpon over 6 years
    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."
  • Stephan Henningsen
    Stephan Henningsen almost 6 years
    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.
  • David A. French
    David A. French over 5 years
    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.
  • Stephan Henningsen
    Stephan Henningsen over 5 years
    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.
  • David A. French
    David A. French over 5 years
    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.
  • Stephan Henningsen
    Stephan Henningsen over 5 years
    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.
  • jrouquie
    jrouquie over 5 years
    "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.
  • Nicholas Cousar
    Nicholas Cousar about 5 years
    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?
  • Murphy
    Murphy about 5 years
    It's 2019, and still no progress on this. Come on! Purging snap right now.
  • Dodgie
    Dodgie over 4 years
    it's the arrogance of it that's most irritating. Uninstalling.
  • Stephan Henningsen
    Stephan Henningsen over 4 years
    Exactly! "So what if we pooped in your homedir? Deal with it!". Which brings us here.
  • 0ne_Up
    0ne_Up over 3 years
    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...
  • Stephan Henningsen
    Stephan Henningsen over 3 years
    This answer has already been suggested. The added --color=tty doesn't have anything to do with the issue at hand. Otherwise, welcome =)
  • Suzanne Soy
    Suzanne Soy over 3 years
    @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'
  • rubenscf2
    rubenscf2 about 3 years
    This also works well with KDE / Kubuntu's Dolphin file manager. Thanks!
  • Martin
    Martin over 2 years
    Something is happening: github.com/snapcore/snapd/pull/10836