stow(8)
stow(8) π
okay bestie, welcome to the User Contributed Perl Documentation section of the manual, and specifically to stow(8) β yes it's section 8, yes that's the "admin commands" section, we're fancy like that π
β¨ NAME β¨
stow β manage farms of symbolic links ππ (not actual cows, it's a metaphor, stay with me)
πΈ SYNOPSIS πΈ
stow [ options ] package ...
π DESCRIPTION π
So this manual page describes GNU Stow 2.4.1. Lowkey important: this is not the definitive documentation for Stow. For the real, full, canon version, go read the accompanying info manual, like by typing info stow. β¨
Stow is a symlink farm manager. What does that mean?? It takes distinct sets of software and/or data that live in separate directories on your filesystem, and makes them all appear to be installed in a single directory tree. It's giving illusion magic. πͺ
Originally Stow was born to solve the need to administer, upgrade, install, and remove files in independent software packages without confusing them with other files sharing the same filesystem space. For instance β and this is a throwback β many years ago it used to be common to compile programs such as Perl and Emacs from source. By using Stow, /usr/local/bin could contain symlinks to files within /usr/local/stow/emacs/bin, /usr/local/stow/perl/bin etc., and likewise recursively for any other subdirectories such as .../share, .../man, and so on. π«Ά
While this is useful for keeping track of system-wide and per-user installations of software built from source, in more recent times software packages are often managed by more sophisticated package management software such as rpm, dpkg, and Nix / GNU Guix, or language-native package managers such as Ruby's gem, Python's pip, Javascript's npm, and so on. (the ecosystem really said "we got it from here" π)
However β and this is the plot twist β Stow is still used not only for software package management, but also for other purposes, such as facilitating a more controlled approach to management of configuration files in the user's home directory, especially when coupled with version control systems. dotfiles girlies, this one's for you π
Stow was inspired by Carnegie Mellon's Depot program, but is substantially simpler and safer. Whereas Depot required database files to keep things in sync, Stow stores no extra state between runs, so there's no danger (as there was in Depot) of mangling directories when file hierarchies don't match the database. Also unlike Depot, Stow will never delete any files, directories, or links that appear in a Stow directory (e.g., /usr/local/stow/emacs), so it's always possible to rebuild the target tree (e.g., /usr/local). no cap, it's safe like that π₯
Stow is implemented as a combination of a Perl script providing a CLI interface, and a backend Perl module which does most of the work. (Perl said "I'll handle it" π )
π¦ TERMINOLOGY π¦
okay vocab check, let's get on the same page bestie π
- A "package" is a related collection of files and directories that you wish to administer as a unit β e.g., Perl or Emacs β and that needs to be installed in a particular directory structure β e.g., with
bin,lib, andmansubdirectories. - A "target directory" is the root of a tree in which one or more packages wish to appear to be installed. A common, but by no means the only such location is
/usr/local. The examples in this manual page will use/usr/localas the target directory. - A "stow directory" is the root of a tree containing separate packages in private subtrees. When Stow runs, it uses the current directory as the default stow directory. The examples in this manual page will use
/usr/local/stowas the stow directory, so that individual packages will be, for example,/usr/local/stow/perland/usr/local/stow/emacs. - An "installation image" is the layout of files and directories required by a package, relative to the target directory. Thus, the installation image for Perl includes: a
bindirectory containingperlanda2p(among others); aninfodirectory containing Texinfo documentation; alib/perldirectory containing Perl libraries; and aman/man1directory containing man pages. - A "package directory" is the root of a tree containing the installation image for a particular package. Each package directory must reside in a stow directory β e.g., the package directory
/usr/local/stow/perlmust reside in the stow directory/usr/local/stow. The "name" of a package is the name of its directory within the stow directory β e.g.,perl.
So basically: the Perl executable might reside in /usr/local/stow/perl/bin/perl, where /usr/local is the target directory, /usr/local/stow is the stow directory, /usr/local/stow/perl is the package directory, and bin/perl within is part of the installation image. see how it all stacks up?? iconic π
- A "symlink" is a symbolic link. A symlink can be "relative" or "absolute". An absolute symlink names a full path; that is, one starting from
/. A relative symlink names a relative path; that is, one not starting from/. The target of a relative symlink is computed starting from the symlink's own directory. Stow only creates relative symlinks. periodt.
β¨ OPTIONS β¨
quick vibe check on the defaults before we get into the flags π§
The stow directory is assumed to be the value of the STOW_DIR environment variable or if unset the current directory, and the target directory is assumed to be the parent of the current directory (so it is typical to execute stow from the directory /usr/local/stow). Each package given on the command line is the name of a package in the stow directory (e.g., perl). By default, they are installed into the target directory (but they can be deleted instead using -D).
okay now the flags, buckle up π
-n,--no,--simulateβ Do not perform any operations that modify the filesystem; merely show what would happen. dry run era, we love a safe little preview π-dDIR,--dir=DIR β Set the stow directory toDIRinstead of the current directory. This also has the effect of making the default target directory be the parent ofDIR.-tDIR,--target=DIR β Set the target directory toDIRinstead of the parent of the stow directory.-v,--verbose[=N]β Send verbose output to standard error describing what Stow is doing. Verbosity levels are from0to5;0is the default. Using-vor--verboseincreases the verbosity by one; using--verbose=Nsets it toN. (yes bestie, you can just keep adding-vand it keeps getting louder π’)-S,--stowβ Stow the packages that follow this option into the target directory. This is the default action and so can be omitted if you are only stowing packages rather than performing a mixture of stow/delete/restow actions.-D,--deleteβ Unstow the packages that follow this option from the target directory rather than installing them.-R,--restowβ Restow packages (first unstow, then stow again). This is useful for pruning obsolete symlinks from the target tree after updating the software in a package. it's giving "clean slate but make it fast" π§Ό--adoptβ Warning! β οΈ This behaviour is specifically intended to alter the contents of your stow directory. If you do not want that, this option is not for you.
When stowing, if a target is encountered which already exists but is a plain file (and hence not owned by any existing stow package), then normally Stow will register this as a conflict and refuse to proceed. This option changes that behaviour so that the file is moved to the same relative place within the package's installation image within the stow directory, and then stowing proceeds as before. So effectively, the file becomes adopted by the stow package, without its contents changing.
fr fr read that warning again. it touches your stow directory on purpose. not a drill π
--no-foldingβ Disable folding of newly stowed directories when stowing, and refolding of newly foldable directories when unstowing.--ignore=REGEX β Ignore files ending in this Perl regex.--defer=REGEX β Don't stow files beginning with this Perl regex if the file is already stowed to another package.--override=REGEX β Force stowing files beginning with this Perl regex if the file is already stowed to another package.--dotfilesβ Enable special handling for "dotfiles" (files or folders whose name begins with a period) in the package directory. If this option is enabled, Stow will add a preprocessing step for each file or folder whose name begins withdot-, and replace thedot-prefix in the name by a period (.). This is useful when Stow is used to manage collections of dotfiles, to avoid having a package directory full of hidden files.
For example, suppose we have a package containing two files, stow/dot-bashrc and stow/dot-emacs.d/init.el. With this option, Stow will create symlinks from .bashrc to stow/dot-bashrc and from .emacs.d/init.el to stow/dot-emacs.d/init.el. Any other files, whose name does not begin with dot-, will be processed as usual.
no more hidden-file chaos in your repo, the dot- prefix ate π
-V,--versionβ Show Stow version number, and exit.-h,--helpβ Show Stow command syntax, and exit.
okay that's part 1 bestie, don't go anywhere β more is coming πΈ
πΈ INSTALLING PACKAGES πΈ
okay so the default action of Stow? it's installing a package. that means making symlinks in the target tree that point into the package tree. and Stow is so efficient about it β it tries to do it with as few symlinks as possible. like, if Stow can make one single symlink pointing to a whole entire subtree inside the package tree, bestie, that's what it's doing. it will NOT make a directory in the target tree and fill it with symlinks. not the vibe. π
so for example β¨ imagine no packages are installed in /usr/local yet β it's completely empty (except for the stow subdirectory obviously, we're not monsters). now suppose the Perl package gets installed. remember it has these directories in its installation image: bin; info; lib/perl; man/man1. so instead of creating the directory /usr/local/bin and populating it with symlinks to ../stow/perl/bin/perl and ../stow/perl/bin/a2p (and so on), Stow creates one single symlink, /usr/local/bin, which points to stow/perl/bin. and it still totally works to refer to /usr/local/bin/perl and /usr/local/bin/a2p, and fewer symlinks got created. this is called "tree folding" π because an entire subtree gets "folded" into a single symlink. iconic behavior honestly.
to finish that example, Stow will also create the symlink /usr/local/info pointing to stow/perl/info; the symlink /usr/local/lib pointing to stow/perl/lib; and the symlink /usr/local/man pointing to stow/perl/man. π¦
now plot twist π suppose that instead of installing Perl into an empty target tree, the target tree isn't empty to begin with. instead it contains several files and directories installed under a different system-administration philosophy. specifically, /usr/local/bin already exists and is a directory, and so do /usr/local/lib and /usr/local/man/man1. in this case, Stow will descend into /usr/local/bin and create symlinks to ../stow/perl/bin/perl and ../stow/perl/bin/a2p (etc.), and it will descend into /usr/local/lib and create the tree-folding symlink perl pointing to ../stow/perl/lib/perl, and so on. as a rule: Stow only descends as far as necessary into the target tree when it can create a tree-folding symlink. it's giving minimal effort, maximum slay.
the time often comes π when a tree-folding symlink has to be undone because another package uses one or more of the folded subdirectories in its installation image. this operation is called "splitting open" a folded tree. it involves removing the original symlink from the target tree, creating a true directory in its place, and then populating the new directory with symlinks to the newly-installed package AND to the old package that used the old symlink.
for example, suppose that after installing Perl into an empty /usr/local, we wish to install Emacs. Emacs's installation image includes a bin directory containing the emacs and etags executables, among others. Stow must make these files appear to be installed in /usr/local/bin, but presently /usr/local/bin is a symlink to stow/perl/bin. so Stow takes the following steps, no cap:
- the symlink
/usr/local/binis deleted - the directory
/usr/local/binis created - links are made from
/usr/local/binto../stow/emacs/bin/emacsand../stow/emacs/bin/etags - and links are made from
/usr/local/binto../stow/perl/bin/perland../stow/perl/bin/a2p
when splitting open a folded tree, Stow makes sure that the symlink it's about to remove points inside a valid package in the current stow directory. safety first bestie π«Ά
π Stow will never delete anything that it doesn't own. π
Stow "owns" everything living in the target tree that points into a package in the stow directory. anything Stow owns, it can recompute if lost. note that by this definition, Stow doesn't "own" anything in the stow directory or in any of the packages. ngl that's a very clear boundary and we respect it.
if Stow needs to create a directory or a symlink in the target tree and it cannot because that name is already in use and is not owned by Stow, then a conflict has arisen. see the "Conflicts" section in the info manual. π€
ποΈ DELETING PACKAGES ποΈ
when the -D option is given, the action of Stow is to delete a package from the target tree. note that Stow will not delete anything it doesn't "own". and deleting a package does not mean removing it from the stow directory or discarding the package tree. so like, the package is fine, it's just not linked anymore. she's just not in the group chat. π
to delete a package, Stow recursively scans the target tree, skipping over the stow directory (since that's usually a subdirectory of the target tree) and any other stow directories it encounters (see "Multiple stow directories" in the info manual). any symlink it finds that points into the package being deleted gets removed. any directory that contained only symlinks to the package being deleted gets removed. and any directory that, after removing symlinks and empty subdirectories, contains only symlinks to a single other package, is considered to be a previously "folded" tree that was "split open." Stow will re-fold the tree by removing the symlinks to the surviving package, removing the directory, then linking the directory back to the surviving package. the glow-up in reverse β¨
π RESOURCE FILES π
Stow searches for default command line options at .stowrc (current directory) and ~/.stowrc (home directory) in that order. if both locations are present, the files are effectively appended together. bestie behavior fr fr π
the effect of options in the resource file is similar to simply prepending the options to the command line. for options that provide a single value, such as --target or --dir, the command line option will overwrite any options in the resource file. for options that can be given more than once, --ignore for example, command line options and resource options are appended together.
environment variables and the tilde character (~) will be expanded for options that take a file path.
the options -D, -R, -S, and any packages listed in the resource file are ignored. sorry to them specifically π
see the info manual for more information on how stow handles resource file.
π SEE ALSO π
the full documentation for stow is maintained as a Texinfo manual. if the info and stow programs are properly installed at your site, the command
info stow
should give you access to the complete manual. go read it, it's the director's cut π
π BUGS π
please report bugs in Stow using the Debian bug tracking system.
currently known bugs include:
- the empty-directory problem. π
if package foo includes an empty directory β say, foo/bar β then if no other package has a bar subdirectory, everything's fine. if another stowed package quux, has a bar subdirectory, then when stowing, targetdir/bar will be "split open" and the contents of quux/bar will be individually stowed. so far, so good. but when unstowing quux, targetdir/bar will be removed, even though foo/bar needs it to remain. a workaround for this problem is to create a file in foo/bar as a placeholder. if you name that file .placeholder, it will be easy to find and remove such files when this bug is fixed.
- when using multiple stow directories (see "Multiple stow directories" in the info manual), Stow fails to "split open" tree-folding symlinks (see "Installing packages" in the info manual) that point into a stow directory which is not the one in use by the current Stow command. before failing, it should search the target of the link to see whether any element of the path contains a
.stowfile. if it finds one, it can "learn" about the cooperating stow directory to short-circuit the.stowsearch the next time it encounters a tree-folding symlink.
not me reading the bug list like a gossip thread π but hey, at least they're documented!
π¦ AUTHOR π¦
this man page was originally constructed by Charles Briscoe-Smith from parts of Stow's info manual, and then converted to POD format by Adam Spiers. the info manual contains the following notice, which, as it says, applies to this manual page, too. the text of the section entitled "GNU General Public License" can be found in the file /usr/share/common-licenses/GPL on any Debian GNU/Linux system. if you don't have access to a Debian system, or the GPL is not there, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA, 02111-1307, USA. π
π COPYRIGHT π
Copyright (C) 1993, 1994, 1995, 1996 by Bob Glickstein <bobg+stow@zanshin.com>; 2000, 2001 by Guillaume Morin; 2007 by Kahlil Hodgson; 2011 by Adam Spiers; and others.
permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. β¨
permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided also that the section entitled "GNU General Public License" is included with the modified manual, and provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.
permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Free Software Foundation.
and that's the whole page bestie π«Ά this was stow(8) from perl v5.38.2, dated 2024-09-08. stay stowed, stay slay π
π
π¦ where this page comes from
- alpine 3.24: stow-doc 2.4.1-r1 Β· GPL-3.0-or-later
- arch rolling: stow 2.4.1-1 Β· GPL-3.0-only
- epel 10: stow 2.4.1-1.el10_3 Β· GPL-3.0-or-later
- fedora 43: stow 2.4.1-3.fc43 Β· GPL-3.0-or-later
- fedora 44: stow 2.4.1-4.fc44 Β· GPL-3.0-or-later
- nixos 26.05: stow 2.4.1
- nixpkgs unstable: stow 2.4.1
- opensuse-leap 16.0: stow 2.4.1-bp160.1.11 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms