16 ms·
Dotfile madness (2019)
- geoffmcc 4y agoPersonally I like my dots but I am pretty novice and I do use GNU stow.
- Macha 4y agoA lot of software that does not default to using XDG directories can be coerced into it, usually with environment variables or just manually creating config in a secondary supported XDG location - the arch wiki is the best source of info on that: https://wiki.archlinux.org/title/XDG_Base_Directory https://wiki.archlinux.org/title/XDG_Base_Directory
- bee_rider 4y agoEh, I dunno. XDG is just some group or whatever, dropping config files in .programname is the de-facto community standard. If people want to follow XDG that's fine, but I can't blame anybody who wants to ignore all that noise.
- slondr 4y agoXDG has real practical benefits, though.
- fiddlerwoaroof 4y agoI personally hate the XDG directories. It’s annoying for different part of an application’s data to be split between `~/.config`, `~/.Cache`, etc. Rather than for all the data for the `foo` program to be in a file named something like `~/.foo*`
- kragen 4y agoI find it useful; I might want to version-control .config but definitely not .cache. And if the program is broken I might blow away .cache but not .config.
- fiddlerwoaroof 4y agoThat still works if it’s `~/.foo/cache`
- Macha 4y agorm -r ~/.foo/cache ~/bar/cache ~/baz/data/app/cache [20 more apps..] is less ergonomic than rm -r ~/.cache/\*
- Macha 4y agoI think HN escaped the * in that final line before I edited it into a code block and my edit window is expired so I can't fix it
- fiddlerwoaroof 4y agoThere’s always: rm -rf ~/.*/cache
- Macha 4y agoAssumes the app uses cache as it's cache, rather than names like dlcontent, bananas_content, storage.sqlite, assets, meta, $TIMESTAMP.txt etc.
- fiddlerwoaroof 4y agoWell, I don’t mind standards, I just prefer all the files an app touches to be under a single root folder (that’s not just $HOME)
- jsmeaton 4y agoAsked out of ignorance, but do the envvars not allow one to easily co-locate data/config/cache by setting them all to the same value?
- fiddlerwoaroof 4y agoNot in a way that would be useful here, I think: I prefer ~/.firefox/cache to ~/.cache/firefox and this requires the variables being unique per program (although, you could probably wrap each program with a script that sets the relevant environment variables to achieve this effect)
- jsmeaton 4y agoI was thinking along the lines of ~/.data/{prog} without requiring further subdirs. The config, data, and cache would all coexist within the same directory per program Each of the data, config, and cache envvars would all be set to ~/.data in this setup (though “data” isn’t a name I’d use)
- codedokode 4y agoIt is convenient because you can delete ~/.cache any time without losing configuration files.
- hyperupcall 4y agostrongly disagree - as of 2022, more apps follow the XDG Base Directory Specification than not - in fact, by a wide margin. So by "doing dirty" in your users home directory, you're going against the grain of the ecosystem. It doesn't seem like you understand much about the specification? I'd recommend reading it, or at least a short summary I've made available here: https://xdgbasedirectoryspecification.com/ https://xdgbasedirectoryspecification.com/
- kragen 4y agoMy home directory has dotfiles for aspell, bash, bzr, cargo, Clojure, CPAN, CVS, Darcs, D-BUS, Dillo, DOSBox, DOSEmu, Emacs, Eclipse, Emacs, ESD, FLTK, fontconfig, FontForge, GForth, GHC, the GIMP, Git, GnuPG, Gnuplot, Guix, IceWM, Idle, Java, John the Ripper, Jython, Links2, MilkyTracker, Mozilla (Firefox), MPlayer, Nethack, Octave, Racket, R, Skeinforge, Slic3r, SSH, SQLite, Subversion, Units, Vim, W3M, WINE, X-Windows, XScreenSaver, and zsh, which is 51 "apps". Some of those have been there since last millennium, and it would not improve my user experience for those "apps" to look for my configuration file in two different places, or to stop looking in the place they've been looking for decades. (God forbid I should use remote CVS again, but if I do, I sure don't want to have to debug where the fuck it's sticking .cvspass now.) There are another 41 things in .config, including Bitcoin, Calibre, Chromium, DjVuLibre, Gomuks, htop, Inkscape, Mumble, OpenSCAD, Transmission, and other things. If I had to choose, I would say that those are the things "going against the grain of the ecosystem". But I think it's fine. As long as it doesn't change in another ten years to be .Config, or .conf, or Configuration, or either Configuration or Configuración depending on whether I installed the machine in English or Spanish. Because then I am seriously going to look into government surplus cruise missiles.
- guilherme-puida 4y ago> it would not improve my user experience for those "apps" to look for my configuration file in two different places Some of those already do, though. At least Vim and Emacs do, and I personally have zsh in .config as well.
- 4y ago
- pigbearpig 4y agoXDG is like four env vars. Doesn’t seem like much noise.
- smeagull 4y ago> dropping config files in .programname is the de-facto community standard. Fuck you so much.
- dang 4y agoPosting like this will get you banned on HN. No more of this, please, regardless of how strongly you feel about config files. Also, would you please stop posting unsubstantive/flamebait comments more generally? It's not what this site is for, and it destroys what it is for. https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html
- claytongulick 4y agoThere's no call for that. I don't have the ability to flag, @dang or others?
- alwillis 4y agoIf people want to follow XDG that's fine, but I can't blame anybody who wants to ignore all that noise. Literally every program I’ve installed for the last several months--WezTerm, Neovim, bat, broot and many more just use XDG by default. Most of the time, the user doesn’t have to do anything, though they might initially be confused if they’re looking for their config files.
- scintill76 4y ago> XDG is just some group vs > the de-facto community standard Feels like you’re just selectively defining “community” to exclude XDG. Maybe there’s a good reason, but you haven’t really described it. Whoever defined $HOME as a place to stick configuration files was also “just some group.”
- blueflow 4y agoFreedesktop (new name for XDG) is not the community. They are some people with a bad reputation when it comes to software quality and maintenance.
- chimprich 4y ago> XDG is just some group or whatever So are ISO, W3C, IETF, etc. > dropping config files in .programname is the de-facto community standard Dropping litter and open-air defecation are de-facto community standards in some unfortunate parts of the world. That's not an argument to keep doing it.
- theamk 4y ago> You will most likely want to create a default configuration file with sane and sensible default values the first time your program is executed. Please don't. Include the example configuration in your docs (/usr/share/PROG..) and mention it in the manual. Statistically user will have hundreds of apps installed but will only ever customize a small fraction them. So creating config unconditionally on first run is one of the worst contributors to homedir pollution. Another argument is version upgrades: if you create configur on first run, you forever bake in the set of options present in that version. If later a new option is added, user will have no idea about it.
- _vufv 4y agoAlso, idempotency of a tool is a desired property that tool devs often invest a lot of effort in maintaining. Initializing default config on the first run is a trivial way to break it. It's much better to just have a sane implicit default value for each setting when config is not present. Then you can list the default config in your docs or offer a CLI flag --print-default-config or --copy-default-config.
- nyuszika7h 4y agoI agree, at least if there is nothing that absolutely has to be specified for the program to work.
- rozab 4y agoI don't see much of a problem with them being initialized in $XDG_CONFIG_HOME/<program>
- hyperupcall 4y agoI completely agree! That's why I created this site: https://xdgbasedirectoryspecification.com https://xdgbasedirectoryspecification.com. We need some place where people can immediately understand the practical benefit, and the minimum ask of their users. Of course, it doesn't help just to complain about the issue in a void, so I've also submitted like 10 PRs and filed quite a few issues. Projects like pnpm and Poetry took note, and now they comply! Someone's gotta clean up house, and I don't mind doing the dirty work.
- inktype 4y agoThe idea for your site is great. A quick suggestion: if you want everyone to immediately understand and sympathize with your cause, then use the tools that everyone knows in your examples. Using some long exa incantation risks alienating people that don't care about things like the latest trendy grep alternative. Just use: `ls -d .*` or `ls -a`
- hyperupcall 4y agoThanks for the suggestion - agreed, I'll make that change
- alwillis 4y agoUsing some long exa incantation risks alienating people that don't care about things like the latest trendy grep alternative Exa is the latest, trendy ls alternative. I don’t think you should remove the Exa example but you certainly should show how to use ls to do something similar for those people still living in the dark ages—ls was created in the 1970s and it hasn’t kept up with the times all that well [1]. I created an ‘ll’ alias for Exa using the Fish shell; obviously you make shell-appropriate aliases in Bash or Z shell: function ll exa --color always --long --no-user --no-permissions --all --icons $argv end [1]: https://the.exa.website/introduction https://the.exa.website/introduction
- inktype 4y agoI appreciate that you are trying to be helpful, but you might be over-evangelizing trendy things at the risk of appearing patronizing; exa is a thing like the latest trendy grep alternative, and the point of my original comment still stands. No need to have a rosetta stone of alternatives to demonstrate an illustrative example where the basic tool that everybody already knows and understands at a glance works. I'm not saying that exa, or fish, or ripgrep, or any other trendy tool is bad.
- slbtty 4y agoThe solution is simple, stop messing your home and put personal data in /home/you/personal/ source code in /home/you/src/ The home is not a place supposed to store random "regular files"
- int_19h 4y agoOn the contrary, that's exactly what it's supposed to be.
- systemvoltage 4y agoYeah but no putting the genie back in the bottle. So the next best is to find another place as your home as the OP explains. That's what I do.
- slbtty 4y agoThe $HOME in unix is a user data storage location A lot of data is managed by software and by convection there is a dot before them Unmanaged/Arbitrary data like random pictures or notes are personal and should end up in $HOME/personal git repos are special managed data, thus they all end up in $HOME/sources $HOME is supposed to let software to create their data folder and optimally without the dot The data here includes config (which is read & write like data file) $HOME/.config or XDG spec is monkey patch that do the wrong thing. GUI file manager should open $HOME/personal as initial location Terminal should open $HOME to let user access software's data file with shorter path (aka without .config/ ) You don't know if i am mad or being brilliant or simply brain dead, but i am making perfect scene.
- wruza 4y agoYes, for users who weren’t scared of .ssh and even edited its contents from time to time. Because these were just their files, not “junk from apps and configs that hurt my sense of beauty”. Those who want to live in a clean folder - mkdir it.
- pacifika 4y agoProbably not in the roots home directory? ~/me/ feels good.
- belltaco 4y agoWhy do they have Steam installed if there is no desktop environment?
- basilgohar 4y agoMany game servers can run natively on Linux and are still installed and launched via Steam.
- az_reth 4y agoAlso there are desktop-less yet graphical ways to use Linux, such as tiling window managers
- e63f67dd-065b 4y agoI think the ship's long sailed. Too much software just throws random crap into $HOME, so it's best to give up. I've resigned myself to the state of affairs and my "real" $HOME is in $HOME/code $HOME/home. As the saying goes, layers are only added, never removed. The world where people respect XDG is not one that can be achieved anymore.
- hyperupcall 4y agoWhich software in particular? Given my experience, it is well within reach, besides a few exceptions including Firefox/Thunderbird, etc, and one relating to Chromium-based browsers. The trick is to use the XDG Base Dir Spec, only if the old ~/.name location doesn't exist. Old users are happy because it doesn't break compatibility and new users are happy because nobody's dropping 10 sacks of potatoes on their metaphorical doorstep
- e63f67dd-065b 4y agoJust a random sample from my home directory right now on a random dev server: .ssh, .gnupg, .vscode-server, .zshrc, .ipython, snap, .antigen, .pki, .profile, .python_history, and there's much more. I don't know what's the situation with desktop linux, may it's better, maybe it's worse, but even on a headless dev server it's already a lost cause. Trying to convince everybody to move to a new standard is a hopeless task, imo, best to move on.
- hyperupcall 4y agoOh right I forgot about those - I set some environment variables so I don't see any of those except for .pki And in my opinion .ssh and .gnupg are okay since in some contexts, the "XDG variables" haven't been initialized in certain circumstances when using those utilities. But yeah, I'll have to look into those - maybe there is something I can do to fix that
- crazytalk 4y agoI think it is better to think about it as XDG failing to respect a world that existed long before it did. $HOME/.* namespace belongs to the user, but contents are special. It's almost like complaining about Linux enforcing the naming of certain file extended attributes.
- yummypaint 4y agoWhile i agree dotfiles aren't the best, i'm concerned about creating too many alternatives. Then we risk ending up in this situation: https://xkcd.com/927/ https://xkcd.com/927/ As someone who uses linux to get other tasks done, rather than as a hobby in itself, I would rather have an aesthetically sub-optimal standard than have no idea what's going on.
- hyperupcall 4y agowhat other "alternatives" are you speaking of on Linux?
- int_19h 4y agoThis isn't some kind of new stuff. I'm not quite sure how old the XDG BDS spec is, but it's been at least 15 years; and the broad notion of using ~/.config rather than dumping stuff directly into ~ is older still.
- dang 4y agoDiscussed at the time: Dotfile madness - https://news.ycombinator.com/item?id=19063727 https://news.ycombinator.com/item?id=19063727 - Feb 2019 (514 comments)
- nathanaldensr 4y agoI think the real culprit here are operating systems and file systems, not programmers (of end-user applications). File systems were designed during an era where semantic meaning was just not important; all file systems cared about (and still care about) are directories and files. The whole paradigm should've been abandoned long ago for something much cleaner.
- frizlab 4y agoLike what?
- throwamon 4y agoNix + home-manager. Boom.
- transfire 4y agoCan you elaborate? How does that solve the problem?
- leoh 4y agonix home manager is very good. The idea is that instead of creating a bunch of dotfiles and having to read a bunch of documentation, one declaratively states which features they want, say, for zsh or vim or git or xdg, etc; and then home-manager will create and manage them (typically they live in `$HOME/.config/whatever`). https://github.com/nix-community/home-manager https://github.com/nix-community/home-manager. Some examples on GitHub: https://github.com/search?q=filename%3Ahome.nix https://github.com/search?q=filename%3Ahome.nix.
- delta_p_delta_x 4y agoWhat I personally find more egregious are dotfiles and dot-dirs on Windows, created by half-baked ports of Unix-first software (such as `ssh`). Windows has `%APPDATA%` and `%LOCALAPPDATA%` that are accessible with `ShGetKnownFolderPath`[0], using the appropriate `KNOWNFOLDERID`[1]; all programs should put their configuration and cache data in these paths. Windows also doesn't know what the dot at the beginning of a file/folder means. Instead, it and NTFS have something that's arguably better: a hidden file attribute `FILE_ATTRIBUTE_HIDDEN`[2], that's again settable/gettable when a file/directory is created or polled, rather than regex-ing for a full-stop. The worst irony is Microsoft software creating dot-files and dot-dirs on Windows[3][4][5]. [0]: https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shgetknownfolderpath https://learn.microsoft.com/en-us/windows/win32/api/shlobj_c... [1]: https://learn.microsoft.com/en-us/windows/win32/shell/knownfolderid https://learn.microsoft.com/en-us/windows/win32/shell/knownf... [2]: https://learn.microsoft.com/en-gb/windows/win32/api/fileapi/nf-fileapi-setfileattributesa?redirectedfrom=MSDN https://learn.microsoft.com/en-gb/windows/win32/api/fileapi/... [3]: https://github.com/dotnet/sdk/issues/8678 https://github.com/dotnet/sdk/issues/8678 [4]: https://github.com/OmniSharp/omnisharp-roslyn/issues/953 https://github.com/OmniSharp/omnisharp-roslyn/issues/953 [5]: https://github.com/microsoft/vscode/issues/3884 https://github.com/microsoft/vscode/issues/3884
- CGamesPlay 4y agoIs “..” the official way to get a parent directory on Windows? Or do they have some other API and the “..” is just a nod to UNIX compatibility?
- quickthrower2 4y agoPeople are simply just lead by example: ~/.bashrc, ~/.bash_profile, ~/.profile, etc.
- remram 4y agoIndeed, the XDG specification is rather young in the history of UNIX.
- pie_flavor 4y agoThe shell profile is a fundamental part of using a Linux computer. It affects how every single program is launched. This is not the same as a utility program's config file.
- wruza 4y agoI don’t see how my prompt function or aliases are more fundamental than vim, git or other rc’s. It affects how every single program is launched That is true, but used as an argument for this subject is tangential and overblown. Look at your .bashrc and tell which parts are too fundamental to not be stored elsewhere, if really needed.
- pabs3 4y agoThis is kind of a thing of the past with Flatpak, since apps can only create files within their sandbox's $HOME, which isn't the same as the user's $HOME. Now we just need deb/rpm/etc apps to be sandboxed in a similar way using bubblewrap (the tool Flatpak uses for sandboxing).
- helf 4y agoYeah… but then you are using flatpaks.
- aliqot 4y agoIf you'd have said this way back I'd have had my hands up like "What's wrong with flatpak", but as I moved to smaller hardware, I started to realize how much space a mainly flatpak environment takes up. It kind of makes sense in retrospect, so I'm not sure what I was expecting.
- anonyme-honteux 4y agoDoes anyone know of any small library in JavaScript/python/go/rust or any language that people use to write CLI apps that makes it trivially easy to implement this spec, even better if it also supports similar conventions for MacOS and Windows?
- richardwhiuk 4y agohttps://docs.rs/dirs/latest/dirs/index.html https://docs.rs/dirs/latest/dirs/index.html
- codedokode 4y agoThis problem can be solved by simply not storing anything in the home directory. Kepp your files in a separate directory like /data or /files and leave home directory for configs. Storing your files in /home is also bad because usually /home uses Linux-specific filesystem and you won't be able to access your files from Windows. Storing files in NTFS partition solves this problem.
- wruza 4y agoWhat if another user wants to keep their personal files on a computer too? Create /data2? This is what /home/$USER/ is for. Also, /home may be mounted anywhere, including some NTFS partition.
- wyclif 4y agoThere are shell scripts like xdg-ninja that can help with this: https://github.com/b3nj5m1n/xdg-ninja https://github.com/b3nj5m1n/xdg-ninja
- transfire 4y agoI’ve been a big fan of XDG for well over a decade. But I am yet stunned by how many big name projects still ignore it. XDG is a great standard, but it seems it’s not enough. Probably time to abandoned home and put all personal files somewhere else — a subdirectory of home will do. And no standard name — call it what you want so no one can hijack it either.
- leoh 4y agoSurprised no one has mentioned nix home manager, which deals with dotfiles in an incredibly elegant way. https://github.com/nix-community/home-manager https://github.com/nix-community/home-manager
- tuyiown 4y agoI've open the project link, scanned the docs, I could not figure out where do find a general description of the problem it tries to solve, and the solution advantages. You made me curious and didn't deliver ! The anguish !
- leoh 4y agohttps://news.ycombinator.com/item?id=33313657 https://news.ycombinator.com/item?id=33313657
- throwamon 4y agoI did, but I shouldn't have because I was too lazy to explain what it is. https://news.ycombinator.com/item?id=33311958 https://news.ycombinator.com/item?id=33311958
- ceving 4y agoI do not understand the problem with "dot"-files. And I do not understand the benefit to have them in another directory. I think there are more important problems to solve in this world.
- rswail 4y agoAre there more important things to solve? Of course. However, this particular topic on this particular message board is about dotfiles and the alternatives. Dotfiles are a clumsy mechanism that came from the early days of Unix. There are better alternatives that provide the same lack of "unknown/unnecessary" directories and files in the user's home directory/folder. Each of Windows/MacOS/XDG-compliant OSs has the equivalent of: 1. A configuration directory 2. A storage directory that is maintained between user logins and/or application execution 3. A temporary/cache directory that is not guaranteed to be maintained between user logins or application execution. The different languages/runtimes also have ways of retrieving these locations which are cross-platform but return the correct values and should be used by all applications that are written to modern standards.
- wruza 4y agoThis sounds like “let’s design something nobody ever will use”. Compare how often you (or anyone) created, edited, deleted or backed up a ~/.dotfile vs some file who-tf-knows-where in AppData or Library mazes. These have near zero discoverability and expect-ability. There are better alternatives Let’s define “better” first.
- fergie 4y agoSurely config goes in $HOME and thats that? I dont see how specifying another directory makes life any easier.
- chimprich 4y agoThe article lists several advantages. If you don't like having a separate directory for config files you can set your XDG variables appropriately.
- yndoendo 4y agoLooks like the python code has a bug, absolute paths are rejected. ``` if config_dir == '' or config_dir[0] == '/': ```
- account42 4y ago> a Desktop directory. That last one has been created by Steam, which is quite unfortunate as I simply do not have a desktop or a desktop environment on my machine. Chrome and a number of other software insists on creating some of these directories (e.g. Downloads) too. However you can fix that by setting XDG_DESKTOP_DIR and XDG_DOWNLOAD_DIR in ${XDG_CONFIG_HOME}/user-dirs.dir to something else (e.g. your home directory).
- Beltalowda 4y agoI have tried everything under the sun, including user-dirs.dir: % cat ~/.config/user-dirs.dirs XDG_DESKTOP_DIR="$HOME" XDG_DOWNLOAD_DIR="$HOME" Yet still: % ls -ld ~/Desktop drwxr-xr-x 2 mt mt 4096 Oct 22 18:04 /home/mt/Desktop/ Sometimes there's a ~/Downloads directory too. But not today. I have no idea what keeps creating these. It's pretty annoying as I have a lot of intentionally short-named things in my ~ for easy shell usage, and it really sticks out. inotify doesn't support reporting the PID of the process that triggered the event, but it seems fanotify does. Maybe I should set up a watcher for this.
- commotionfever 4y agotry systemctl enable --now xdg-user-dirs-update.service and just to be safe I have a snippet that parses that file and exports the variables in my login shell like .profile (fish in this example but would be similar for other shells) sed -nE 's/^([^=#]+)=(.*)/set -gx \1 \2/gp' <"$XDG_CONFIG_HOME/user-dirs.dirs" | source
- noiwillnot 4y agoTry to set enabled=False in ~/.config/user-dirs.conf https://www.unix.com/man-page/centos/5/user-dirs.conf/ https://www.unix.com/man-page/centos/5/user-dirs.conf/
- SadWebDeveloper 4y agoYou are not gonna like the solution to that problem: Windows Registry like configuration file. Centralization solve the problem in this case but have the downside that the central configuration file will become bloated and requires more memory in the long run.
- quickthrower2 4y agoThe Windows equivalent madness is all the virtual folders for Documents, Downloads etc. that show in explorer without the full path (so no copy/pasting that path for you sir!), and may be mapped to some other place and suchlike. OneDrive takes over in a way that I always uninstall it and forgo the 1Tb of storage they give me for free with O365! As well as some stuff dumped in the home directory too. The defense on both Windows and Linux is to just keep your own documents elsewhere, or at least in a subfolder of the home directory.