Adding pre-link, post-link and pre-unlink scripts
You can add scripts to a recipe. These scripts are executed in a subprocess by
/bin/bash <script> on Linux and macOS, and
%COMSPEC% /c <script> on Windows.
The convention for the path and filenames of these scripts on Windows is:
On Linux and macOS, the convention is:
<name> is the package name and
<action> is one of the following:
pre-link—Executed before the package is installed. An error is
indicated by a nonzero exit and causes conda to stop and causes the
installation to fail.
post-link—Executed after the package is installed. An error is
indicated by a nonzero exist and causes installation to fail. If there is an
error conda does not write any package metadata.
pre-unlink—Executed before the package is removed. An error is
indicated by a nonzero exist and causes the removal to fail.
EXAMPLE: When there is a script named
/bin/.foo-post-link.sh in the package
foo-1.0-0.tar.bz2, it is executed after the package is installed.
The scripts set the following environment variables:
||The install prefix.
||The name of the package.
||The version of the package.
||The build number of the package.
The scripts are:
- macOS and Linux:
Post-link and pre-unlink scripts should:
- Be avoided whenever possible.
- Not touch anything other than the files being installed.
- Not write anything to stdout or stderr, unless an error occurs.
- Not depend on any installed or to be installed conda packages.
- Depend only on simple system tools such as
The scripts should not write to stdout or stderr unless an error occurs, but
they may write to
$PREFIX/.messages.txt, which is shown after conda
completes all actions.