Environment and PATH

A command that works in Terminal can fail on a Schedule because it gets a different environment. Crontastic builds each Run's environment the same way every time, from layers you control, and records what the Run got.

How a command runs

Each Run starts your login shell as $SHELL -l -c '<command>', with input from /dev/null, in the Job's working directory (your home folder if none is set). A multi-line command runs line by line in that one shell.

By default the last line's exit code decides the Outcome. With Stop at the first failing line on (stop_on_error = true), the command runs after set -e, so the first failing line ends the Run as Failed. New Jobs made in the app or over MCP have it on.

The layers

A Run's environment is built in layers. Later layers win.

  1. Base. HOME, USER, LOGNAME, SHELL, TMPDIR, LANG, LC_*, and PATH=/usr/bin:/bin:/usr/sbin:/sbin. It never depends on how Crontastic was opened, from Finder, at login or from Terminal.
  2. Global env file. ~/.config/crontastic/env, applied to every Job, if it exists.
  3. Group env file. ~/.config/crontastic/groups/<Group>.env, applied to the Group's Jobs, if it exists. A Group called Data uses groups/Data.env; a / or : in the name becomes -.
  4. The Job's env_file. If it's set, it must exist: a missing file fails the Run.
  5. The Job's env. Variables set in the Job editor, or in the [env] table of the Job file.
  6. The Run Context. The CRONTASTIC_* variables, which always win. See the Run Context.

Env files have one KEY=VALUE per line. Blank lines and lines starting with # are ignored, an export prefix is allowed, and values can be in single or double quotes. A file that can't be read fails the Run with the line number.

# ~/.config/crontastic/groups/Data.env
DB_HOST=localhost
REPORT_DIR="/Users/you/Reports"

Extending PATH

A PATH line in any layer can extend the PATH below it with $PATH or ${PATH}:

# ~/.config/crontastic/env
PATH=/opt/homebrew/bin:$PATH

Only $PATH is expanded. Other variables and ~ are not, so write the home folder out in full: /Users/you/bin, not ~/bin.

After the layers, the login shell's profile runs and can add to PATH too, as it does in Terminal. On macOS the system profile reorders PATH and would push the folders your layers added to the end; Crontastic puts them back in front, so they win over a same-named tool elsewhere.

Why .zshrc and nvm aren't read

A login shell started with -c isn't interactive. zsh reads .zprofile for it, but not .zshrc. Tools that set themselves up in .zshrc, such as nvm, aren't on the Run's PATH, and the command fails with exit 127, “command not found”.

The fix is to put the folder in Crontastic's global env file, so every Job gets it:

# ~/.config/crontastic/env
PATH=/Users/you/.nvm/versions/node/v22.11.0/bin:$PATH

To find the folder, run dirname "$(command -v node)" in Terminal. Use a Group env file or the Job's env_file instead if only some Jobs need it.

What each Run records

Each Run records the PATH it started with, after the layers and before the login profile, and the names of its environment variables. Values aren't recorded, because env files hold secrets. You can see both on the Run in the app, and agents get them from get_run and test_run.

When a Run exits 127 and its error output says a command was “not found”, the Run shows a hint with the PATH it started with and where to add the missing folder: the global env file, the Group's env file, or the Job's env_file.

Secrets go in env_file, not env

Variables set with env are saved in the Job file, which you might sync or keep in git. Put API keys and passwords in an env file outside the jobs folder, and point the Job at it:

env_file = "~/.secrets/metrics.env"

The env_file path can start with ~. Crontastic's MCP server gives agents the same advice.

Permissions

macOS protects some folders and data, such as Desktop, Documents, Downloads, iCloud Drive, Mail and Photos, and an app needs your permission to read them. macOS treats a Job's command as Crontastic's, so the access it needs has to be granted to Crontastic, not to Terminal.

Crontastic doesn't fix these permissions, and can't grant them for you. A Script that reads protected folders fails with errors such as “Operation not permitted” until you allow it:

  1. Open System Settings › Privacy & Security › Full Disk Access.
  2. Turn on Crontastic. If it isn't listed, click the add button and choose Crontastic in Applications.
  3. Quit Crontastic from the menu bar and open it again.

Crontastic is one signed and notarized app, so that's the one place to grant access for all your Jobs. Grant only what your Jobs need: Full Disk Access lets every Job read everything you can.