Skip to content

Cache data is written to userData dir instead of cache dir #8124

Open

Description

@smyrman
  • Electron version: 1.3.9 (via Atom 1.12.6) and unknown (via Slack 2.3.2)
  • Operating system: Linux

Expected behavior

Files stored by Electron on behalf of electron apps, should follow the XDG Base Directory specification and place only config files in $XDG_CONFIG_HOME/ (default ~/.config/). cache and data files should be placed in XDG_CACHE_HOME (default: ~/.cache) and XDG_DATA_HOME (default: ~/.local/share) respectively.

https://specifications.freedesktop.org/basedir-spec/latest/ar01s03.html

Actual behavior

As seen in Atom and Slack on Linux, they leave non-config files in ~/.config/Atom and ~/.config/Slack/ in particular, they leave folders such as "databases", "GPUCache", "Cache", "logs", and "Local Storage". Atom mention this as an Electron issue in atom/atom#8281 ("where electron stores it's files").

Could still be it's not Electron's fault that the apps store non-config files in these locations, but hopefully you know more than me here.

Activity

  1. kevinsawicki commented on Dec 1, 2016

    @kevinsawicki
    Contributor

    Files stored by Electron on behalf of electron apps

    Chrome provides the paths to these files, it looks like they've labeled this issue as a won't fix in the past.

    https://bugs.chromium.org/p/chromium/issues/detail?id=129861

  2. smyrman commented on Dec 2, 2016

    @smyrman
    Author

    It seams to me though that chromium still uses XDG_CACHE_HOME correctly? Although they do store config and browser history together in XDG_CONFIG_HOME.

    Is it possible for Electron to move folders like GPUCache and Cache to XDG_CACHE_HOME, or are those still defined by Chrome/chromium?

  3. kevinsawicki commented on Dec 2, 2016

    @kevinsawicki
    Contributor

    Is it possible for Electron to move folders like GPUCache and Cache to XDG_CACHE_HOME, or are those still defined by Chrome/chromium?

    Those files are completely managed by Chrome I believe, are you seeing standalone Chrome store them in a different location?

  4. smyrman commented on Dec 2, 2016

    @smyrman
    Author

    I find ~/.cache/google-chrome/Default/
    Cache 'Media Cache'
    and:
    ~/.config/google-chrome/Default/GPUCache

    , so actually, it just seams inconsistent...

    Thanks for the quick reply!

  5. deepak1556 commented on Dec 2, 2016

    @deepak1556
    Member

    Is it possible for Electron to move folders like GPUCache and Cache to XDG_CACHE_HOME, or are those still defined by Chrome/chromium?

    Yup its possible. Currently we set the cache path to app data path in brightray. @kevinsawicki are we ok on changing this ?

  6. kevinsawicki commented on Dec 2, 2016

    @kevinsawicki
    Contributor

    @kevinsawicki are we ok on changing this ?

    Yeah, possibly, I'm not sure why the current behavior was implemented that way so I'd like to understand that. Also changing it means existing apps upgrading will start with a fresh cache right?

  7. smyrman commented on Dec 2, 2016

    @smyrman
    Author

    Also changing it means existing apps upgrading will start with a fresh cache right?

    That doesn't sound dangerous to me, although I'm an outsider here... However to get rid of the old cache, perhaps you could have a move old cache directory on startup if it exists. Then you get to clean up users systems while keeping old cache at the same time, if that's desirable.

  8. deepak1556 commented on Dec 3, 2016

    @deepak1556
    Member

    Also changing it means existing apps upgrading will start with a fresh cache right?

    Yup.

    Maybe we can adopt this with next chromium update release or 2.0 ?

  9. anaisbetts commented on Dec 3, 2016

    @anaisbetts
    Contributor

    I'm okay with moving cache folder, but please do not move user settings folder, this isn't worth breaking every app on the planet. Local Storage / Cookies et al are user data for many apps.

  10. MarshallOfSound commented on Dec 3, 2016

    @MarshallOfSound
    Member

    If we move the cache folder we will have to add internal logic to clean up the old one. I don't want to update Electron versions and suddenly have two caches (which aren't negligible in size) on the users disk.

  11. smyrman commented on Dec 5, 2016

    @smyrman
    Author

    I'm okay with moving cache folder, but please do not move user settings folder, this isn't worth breaking every app on the planet. Local Storage / Cookies et al are user data for many apps.

    @paulcbetts, I think nobody is suggetting to move user settings... user cache should go to XDG_CACHE_HOME ($HOME/.cache by default)

    Ideally, what you refer to as user data (including databases) should go in XDG_DATA_HOME ($HOME/.local/share by default), chrome doesn't In my opinion correctly do this, but many other Linux apps do.

    User Settings are already in the correct place (XDG_CONFIG_HOME, defaulting to $HOME/.config).

    Is it possible for Electron to simply add a startup hook (that can be removed in 2.0) that moves the old content, and if necessary, adds a symlink in the old location? And does it solve all the concern from e.g. @baconface?

  12. MarshallOfSound commented on Dec 5, 2016

    @MarshallOfSound
    Member

    Is it possible for Electron to simply add a startup hook (that can be removed in 2.0) that moves the old content, and if necessary, adds a symlink in the old location? And does it solve all the concern from e.g. @baconface?

    This will be unpredictable and could cause issues with existing applications. Permission issues, copy speeds and all sorts of other things could cause a working application to suddenly become non-working. This change should be opt-in not automatic IMO.

  13. 122 remaining items

  14. added
    stale-exempt
    and removed on Aug 10, 2025
  15. anaisbetts commented on Aug 10, 2025

    @anaisbetts
    Contributor

    This bug should honestly be closed as WONTFIX. While OP is probably right, the time to have fixed it is 10+ years ago; it is Too Late now. Leaving this in the hands of developers to deal with would almost certainly be a complete disaster and even trying to auto-migrate everything behind the scenes would almost certainly break applications.

  16. MicahZoltu commented on Aug 10, 2025

    @MicahZoltu

    it is Too Late now.

    Why is it too late now? I can't think of a reason why this couldn't be fixed now but could have been fixed in the past. It is still a bug, it is still causing problems for users, and it still has the same route to fixing it as before.

    What sorts of disasters are you imagining? What do you believe will go wrong if this is fixed?

    At a bare minimum, you could first check the new correct location, and if that is empty check the old incorrect location and do not do any migration. If both are empty, use the new location. If old exists and new doesn't exist, continue using the old path. This would at least allow for manual migration by apps and users, without forcing a migration on anyone.

  17. odinho commented on Aug 10, 2025

    @odinho

    Agree with the above. This can very well be fixed now.

    We're building a new app on Electron and it'd be very nice to have this correct from the start. I'd also personally fix this for other apps too, since I do remote backup of some of these folders.

  18. severindupouy commented on Aug 10, 2025

    @severindupouy

    bump

  19. heroin-moose commented on Aug 11, 2025

    @heroin-moose

    At this point Electron is beyond repair. Just use Qt guys. It’s hopeless.

  20. likelyrand commented on Nov 10, 2025

    @likelyrand

    almost 9 years and still not fixed, what a joke

  21. genodeftest commented on Nov 10, 2025

    @genodeftest

    If you don't have anything productive to add (like a PR fixing this issue), please stop it. Ranting doesn't help anyone and won't make it more likely that the devs will fix it.

  22. heroin-moose commented on Nov 12, 2025

    @heroin-moose

    Everything productive already here. Multiple people suggested backward-compatible algorithm.

  23. Half-and-Xat commented on Dec 1, 2025

    @Half-and-Xat

    This bug should honestly be closed as WONTFIX. While OP is probably right, the time to have fixed it is 10+ years ago; it is Too Late now.

    Mozilla fixed their issue after 21 years, just a few days ago. So why electron shouldn't be able to implement this? It is just a matter of willingness.

    Today (btw issue also became 9 years old) this bug broke my automated backups and while as experienced user I can fix it, it costs time to do so. It also spams my backups with with new useless data on daily basis on programs that I am not aware of they're storing cache in .configs folder or similar. The one single program I realized today doing it caused 750MB (cache) backup trash in few weeks. I may should look what other installed applications are using electron. Such things creates more troubles to inexperienced users which may do not understand what logs are telling. And in additional it creates additional work to other projects, because they are getting annoying bug reports as mine which you can see above, following the link.

    People will have to deal with it (programmers and users) until it is fixed. So even if it takes another 12 years to fix it, it is still worth doing so.

  24. bysiber commented on Mar 2, 2026

    @bysiber

    This is still a significant issue in Electron apps writing cache data to userData means standard cache cleanup tools miss them entirely. On macOS, this is particularly problematic because Electron apps scatter data across multiple locations:

    Quick audit of Electron app cache on macOS:

    # Electron apps in Application Support (treating cache as user data)
    du -sh ~/Library/Application\ Support/Slack 2>/dev/null
    du -sh ~/Library/Application\ Support/discord 2>/dev/null
    du -sh ~/Library/Application\ Support/Code 2>/dev/null  # VS Code
    du -sh ~/Library/Application\ Support/Microsoft\ Teams* 2>/dev/null
    
    # Where cache SHOULD be (~/Library/Caches)
    du -sh ~/Library/Caches/com.slack.Slack 2>/dev/null
    du -sh ~/Library/Caches/com.microsoft.VSCode 2>/dev/null
    
    # GPU shader cache (often overlooked)
    du -sh ~/Library/Application\ Support/*/GPUCache 2>/dev/null
    du -sh ~/Library/Application\ Support/*/Cache 2>/dev/null
    du -sh ~/Library/Application\ Support/*/CachedData 2>/dev/null

    On my machine, VS Code alone has ~2GB in Application Support (CachedData, CachedExtensions, User/workspaceStorage). Slack: ~1.5GB. Discord: ~800MB. This data should survive a cache clear but currently it is all mixed together with actual config.

    What you can safely clean (Electron apps on macOS):

    # These subdirectories within Application Support are cache-like and safe to remove:
    rm -rf ~/Library/Application\ Support/*/GPUCache
    rm -rf ~/Library/Application\ Support/*/Cache
    rm -rf ~/Library/Application\ Support/*/Code\ Cache
    rm -rf ~/Library/Application\ Support/*/CachedData
    rm -rf ~/Library/Application\ Support/*/Service\ Worker/CacheStorage

    For anyone wanting a visual audit of all these scattered caches, I maintain ClearDisk -- a free macOS menu bar app that scans developer caches (including Electron/VS Code cache directories, Docker, Xcode, node_modules, Homebrew, etc.) and shows exactly what is using disk space. Helpful for catching these "hidden" caches that live outside ~/Library/Caches.

  25. regalialong commented on Mar 2, 2026

    @regalialong

    2025

    Hey, you might wanna check the synchrony of your clocks (i mean both your system and internal one).

  26. MurzNN commented on Jul 17, 2026

    @MurzNN

    Okay, if Electron developers still ignore this critical issue and don't want to fix this, maybe we can start a community-based project with just a script that scans the userData directory and makes symlinks to the XDG_CACHE_HOME directory?

    Or maybe there is already something like this exist? If so, would be great to update the issue description with the section "Workarounds", because a lot of comments in this issue got hidden by default by GitHub.

  27. shvchk commented on Jul 29, 2026

    @shvchk

    @MurzNN I've been using danisztls/ephemeral for a year or two without issues

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    10-x-y11-x-y12-x-y13-x-ybug 🪲stale-exempt

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions