How I install personal versions of programs on Unix
utcc.utoronto.ca
utcc.utoronto.ca
A great tool to manage these home-based installations is GNU Stow. In fact I've written scripts that just take the tarball, compile it with the typical workflow (autotools or cmake), setting prefix and DESTDIR as needed and then use Stow to put it in place. Then if I want to "uninstall" something, I use `stow --delete`. Works well enough for most of the use cases, like installing a newer GCC or Cmake than available on a cluster etc.
`/usr/local` for system level, non-managed packages
`~/.local` for user level, non-managed packages
`/opt` for system level "add-on" packages. Typically proprietary upstreams. Zoom, Discord, the proprietary builds of Chrome or VSC, etc.
For a lot of tools, I find that writing a port can be almost as little work and installing it manually. With the added bonus that the package manager will then track its dependencies and that I can share the port with other users of the distro.
Alpine makes this particularly easy thanks to the simplicity behind its APKBUILD files. BSDs usually have relatively simple recipe format too (although not as simple as APKBUILD or PKGBUILD tbh).
There used to be a "checkinstall" tool, so you'd ./configure, make, and instead of "make install" use "checkinstall" - this would make some fakeroot magic, install the package and create a deb package for it, that could be apt-get removed later.
And iirc, automake uses /usr/local by default (if you didn't specify the --prefix).
* Linux: "/usr/local" or "/opt/local" depending on distro
* NetBSD: "/usr/local", NetBSD packages go into "/usr/pkg". I wish all other systems adopted pkgsrc :(
* OpenBSD: "/opt/local", OpenBSD packages go into /usr/local
If on a system I do not "own", like AIX at work or SDF, I use $HOME/local
/opt would be for canned items. For example, if for some reason on Linux, I want to execute the latest Firefox or Thunderbird I would get the pre-built binaries and extract them in /opt. When I did that in the past, all items will be stored in /opt/firefox and /opt/thunderbird.
Plus many proprietary objects like to be sitting in /opt in their own directories.
OpenBSD uses it. So off to /opt
NetBSD I use it for my items, no need for /opt
Linux I use /opt for my items because some distros throw items there or messes around with /usr/local. Also some proporatary packages I used at work on RHEL tosses items there.
For personal installations you should use $XDG_DATA_HOME: https://specifications.freedesktop.org/basedir-spec/latest/#... and then create symlinks to binaries in $HOME/.local/bin.
For starters, it’s not a UNIX thing. It’s really more a Linux thing. Some Unixes have also adopted it but not enough for someone to argue that someone “should” be using it in reply to an article about Unix more generally.
Secondly, XDG stems from managing desktop applications. Granted there’s no reason it can’t nor shouldn’t be used for CLI tools too. But equally there isn’t any reason why someone needs to use it. And on headless platforms, it makes zero sense to enforce XDG over any other Unix standard.
Lastly, XDG is surprising complicated. Your example of symlinks et al demonstrates just how much additional work you’re doing just to follow XDG here. If you CLI tool doesn’t spew dozens of config files in $HOME then your recommendation isn’t any better than the one in the article.
I really want to like XDG but like many things that originated from Linux, it’s far from an elegant solution to a simple problem and barely supported outside of Linux too. So I can’t blame anyone for deciding not to bother with it for their own personal software on their personal systems.
Secondly, XDG is a much better standard than FHS and actually supports normal users, needing to be root to install a random application is a security vulnerability waiting to happen.
Lastly XDG is not complicated at all. its around 10 envvars pointing to directories that you have to mkdir, its preferable that you put these paths in your .login as a shellscript so they're static, that's it, that's all.
And its well supported, nearly everyone is moving and using $XDG_CONFIG_HOME which is $HOME/.config instead of throwing their configuration files into $HOME/.MYPROGRAM
FWIW I would love if Everyone just used $HOME/.local/$FHS that way everything is reused
But then again a /tmp/usr/$USER or /var/cache/usr/ should also exist, nobody cares.
[1] e.g. if you want to install Python applications in isolated virtual environments, the venv has its own bin/ and lib/ internally - you wouldn't want to flatten that structure and have all those applications share top-level /usr/local/bin and /usr/local/lib, because that would involve manually destroying the venv structure and also defeating the entire purpose of them.
[2] although this is not completely smooth if, like me, you want to compile multiple versions of Python from source and then make venvs based off of them - see https://github.com/python/cpython/issues/106045 .
So after that it's `./configure --prefix=$HOME/p/`, `make install` and `build-personal-path`
I feel like I'm always fighting against the OS just to share files amongst users.
I suppose the answer is probably a deduplicating fs like zfs/btrfs - although, do they dedupe across users (that feels like an exploit route).
I’m not really sure what the issue you’re having is from what you’ve shared. But if the files and have read permissions for the relevant users, groups, or even everyone, then it should “just work”.
Perhaps the issue was with folder permissions? Hidden ACLs? Or shortcut icons? (the way Linux handles application icons is vastly over complicated in my personal opinion)
> I suppose the answer is probably a deduplicating fs like zfs/btrfs - although, do they dedupe across users (that feels like an exploit route).
Why would it be an exploit route? zfs and btrfs are CoW (copy-on-write) file systems which means if someone makes an edit on one copy, it wouldn’t edit both copies.
Maybe you’re thinking of hard links? These aren’t limited to CoW file systems (eg supported by NTFS and ext4) and those could run into issues where one person could update someone else’s “copy”.
Everyone does this; it's pretty standard. Using XDG directories (~/.local/bin) is most common nowadays, but hey, you do you.
It does annoy me that cargo has its own bin directory in ~/.cargo, but I'm too lazy to set the env vars to move it.