Skip to content

Environment variables

Reference

Every environment variable mare reads, grouped by what it controls, and the variables mare sets for the commands it starts. For MARE_<OPTION> configuration variables, the environment wins over init.lua, while command-line flags win over the environment (other sections note their own precedence, such as provider credentials).

This reference page is maintained by hand (not generated by scripts/gen_docs.py).

mare uses XDG-style locations on every platform, including Windows and macOS. See Files for what lives in each directory.

Variable Effect
MARE_HOME Root for all four directories. Config, state, data and cache become config, state, data and cache below it. Wins over the XDG_* variables. Useful for throwaway runs and tests.
XDG_CONFIG_HOME Config directory is $XDG_CONFIG_HOME/mare. Default ~/.config/mare.
XDG_STATE_HOME State directory is $XDG_STATE_HOME/mare. Default ~/.local/state/mare.
XDG_DATA_HOME Data directory is $XDG_DATA_HOME/mare. Default ~/.local/share/mare.
XDG_CACHE_HOME Cache directory is $XDG_CACHE_HOME/mare. Default ~/.cache/mare.
HOME, USERPROFILE The home directory behind the defaults above and behind ~ in paths. USERPROFILE is the Windows fallback.

Empty values count as unset.

Config layers apply in this order, later ones winning: option defaults, state.json, user init.lua, project .mare/init.lua, the MARE_<OPTION> variables below, and finally command-line flags (--set, -m, -e).

Variable Effect
MARE_<OPTION> Sets the core option of the same name, upper-cased: MARE_THEME, MARE_BORDER, MARE_REDUCE_MOTION, MARE_UPDATE_CHECK, and so on. Every core option has one (see Options). The value is parsed as JSON and used as a string when it is not JSON: MARE_REDUCE_MOTION=true, MARE_PERF='{"highlight_cache":64}'. A value that starts with {, [ or " but does not parse is ignored with a warning.
MARE_MODEL, MARE_EFFORT The model and reasoning effort for this invocation. MARE_EFFORT applies to this invocation only.
MARE_TRUST_DEFAULT Default project trust when nothing is recorded: ask, trust or distrust (always and never are accepted too).
MARE_WATCHDOG_MS Per-callback limit in milliseconds for Lua code that never yields. Default 10000. The watchdog starts before init.lua, so it can only be set here or with --set watchdog_ms=....
MARE_LUA_MEMORY_MB Memory limit in MiB for the Lua VM. The VM is created before init.lua, so it only takes effect here or with --set lua_memory_mb=....
MARE_APPROVAL_POLICY Overrides the approvals plugin’s policy option (ask, never, untrusted, or JSON for granular policies).
MARE_WEB_SEARCH_PROVIDER, MARE_WEB_FETCH_PROVIDER Override the web plugin’s search_provider and fetch_provider options.
MARE_MCP_CONFIG Path of an extra MCP configuration file. Its servers start only after approval (--approve-mcps approves them without asking).
MARE_DEV_PLUGINS A directory of built-in plugin sources to load from disk instead of the copies embedded in the binary. For working on mare itself.

Invalid MARE_<OPTION> values are reported at startup; --strict-config turns those warnings into a refusal to start.

A provider reads its key from, in order: the api_key option in init.lua, the credentials stored by mare login, then these variables. See Models.

Variable Provider
OPENAI_API_KEY OpenAI
ANTHROPIC_API_KEY Anthropic
GEMINI_API_KEY, GOOGLE_API_KEY Google (GEMINI_API_KEY is checked first)
OPENCODE_API_KEY opencode Go
DEEPSEEK_API_KEY DeepSeek
MOONSHOT_API_KEY Moonshot (kimi)
KIMI_API_KEY Kimi Code (kimi-code)
OPENROUTER_API_KEY OpenRouter

An OpenAI-compatible provider you define can name its own variable with api_key_env. An api_key option that is the name of an environment variable is read from that variable. MCP server configuration can also pull values from the environment: ${VAR}, ${env:VAR} and ${VAR:-default} in strings, bearer_token_env_var, and env_http_headers.

Variable Effect
HTTPS_PROXY, HTTP_PROXY, ALL_PROXY (either case) HTTP and HTTPS proxy for mare’s own requests. Commands started by mare inherit them unchanged, except in a sandbox that restricts the network: there mare sets the proxy variables to its own local filtering proxy and clears NO_PROXY. SOCKS proxies and PAC files are not supported and fail with an error instead of connecting directly.
NO_PROXY (either case) Hosts that bypass the proxy. When a proxy is set and NO_PROXY is not, commands mare starts get NO_PROXY=localhost,127.0.0.1,::1.
MARE_CA_CERTIFICATE A PEM bundle of extra trusted CA certificates. When set it is the only custom source.
SSL_CERT_FILE A PEM bundle, used when MARE_CA_CERTIFICATE is not set.
SSL_CERT_DIR A directory list (:-separated, ; on Windows) of PEM or .crt files, added to the above.

Certificates are added to the system roots; mare bundles none. A named file that cannot be read, or that contains no certificate, is an error.

With transport = "auto", OpenAI requests use HTTP instead of a WebSocket when HTTPS_PROXY or ALL_PROXY (either case) is set, because the WebSocket client does not go through HTTP proxies.

Variable Effect
NO_COLOR Any non-empty value turns colors off.
MARE_COLOR Forces the color depth: truecolor, 256 or 16. Overridden by NO_COLOR.
COLORTERM truecolor or 24bit selects true color.
TERM 256 in the name selects 256 colors. dumb switches the interface to plain line-by-line output. linux with a non-UTF-8 locale selects ASCII icons.
TERM_PROGRAM, TERM_PROGRAM_VERSION Identify the terminal for color depth, icon set, width rules and image protocol.
COLUMNS Width fallback in plain (TERM=dumb) mode.
MARE_NERD_FONT, NERD_FONT 1 selects the Nerd Font icon set.
LC_ALL, LC_CTYPE, LANG The first one set decides whether the locale is UTF-8.
MARE_WIDTH_METHOD Forces how character width is measured: unicode or wcwidth.
MARE_NO_TERM_PROBE When set, skips all startup terminal queries, including background color and capability probes.
MARE_NO_OSC11 When set, skips only the OSC 11 background-color query; other capability probes still run.

mare also recognizes a terminal from variables it sets, to pick key, image and clipboard behavior: KITTY_WINDOW_ID, GHOSTTY_RESOURCES_DIR, WEZTERM_EXECUTABLE, WEZTERM_PANE, ALACRITTY_WINDOW_ID, ALACRITTY_SOCKET, WT_SESSION, KONSOLE_VERSION, VTE_VERSION, VSCODE_INJECTION, ITERM_SESSION_ID, WARP_SESSION_ID, and the multiplexer markers TMUX, TMUX_PANE, STY and ZELLIJ. You do not set these yourself. Clipboard copy also looks at SSH_TTY, SSH_CONNECTION and WSL_DISTRO_NAME to choose between native and OSC 52 copy.

Variable Effect
VISUAL, EDITOR The external editor, used after the editor option and in that order. The fallback is vi. The value may include arguments, such as code --wait.
SHELL The shell for the bash tool when the tools plugin’s shell option is not set: $SHELL if it is bash or zsh, otherwise bash.
SSH_CONNECTION, SSH_TTY When either is set, mare login assumes there is no local browser and offers the device-code flow first. MCP OAuth login asks you to paste the redirected address.
DISPLAY, WAYLAND_DISPLAY On Linux, when both are empty mare login assumes there is no browser.
Variable Effect
MARE_LOG Log filter for <state>/log/mare.log. A level (debug, trace) or per-module filters (mare_binding=trace). Default info.
MARE_NO_HARDENING 1 skips the startup hardening: no core dumps, no debugger attach, and LD_* / DYLD_* variables removed from mare and its commands.
MARE_FRAME_LOG A file path. mare writes one render time in microseconds per line while the TUI runs.
MARE_SANDBOX_BACKEND none turns off the OS sandbox backend; landlock forces the Landlock backend on Linux.
MARE_SANDBOX_CAPS Comma-separated sandbox capabilities (for example fs_write,net_block) that narrow what the detected backend is allowed to claim.
MARE_SANDBOX_DIR Windows: the enhanced sandbox directory. Default %ProgramData%\mare\sandbox.
MARE_SANDBOX_HELPER Windows: the executable that serves as the sandbox runner, instead of mare itself.
MARE_UPDATE_SNAPSHOTS Controls snapshot updates for mare test (always updates snapshot files directly, equivalent to --update-snapshots).
MARE_PROFILE_LUA_EVERY Lua instruction sampling interval for startup profiling (--profile-startup / --startuptime); positive integer, default 1000000.
MARE_VALIDATE_RECORDS 1 enables strict session storage record validation in release builds.
MARE_FAUX_SCRIPT A file holding a JSON array that scripts the faux test provider (available only in debug builds or builds compiled with the faux feature; release binaries omit it).

Commands run by the bash tool and other tools start from your environment with two changes. A hook command such as notify.cmd gets only the first change (the credential scrub), not the additions below.

Credential-shaped names are removed. Any variable whose name contains KEY, PASSWORD, SECRET or TOKEN (any case) is dropped, and so is every MARE_* variable. Adjust this for the bash tool and mare.tool.command tools with the env option of the tools plugin: include, exclude, and set all apply to both:

mare.plugin("tools", {
env = {
include = { "GH_TOKEN" }, -- keep a name the scrub would drop
exclude = { "AWS_PROFILE" }, -- drop a name it would keep
set = { PAGER = "less" }, -- set a value for every tool command
},
})

Then mare adds these for tool commands:

Variable Value
TERM dumb
PAGER, GIT_PAGER, GH_PAGER cat
NO_COLOR 1
LANG, LC_CTYPE C.UTF-8 (en_US.UTF-8 on macOS), only when none of LANG, LC_ALL, LC_CTYPE is set. Not set on Windows.
MARE_CWD The session’s working directory.
MARE_SESSION_ID The session id.
MARE_SESSION_MODEL, MARE_SESSION_EFFORT The current model reference and effort. They are named MARE_SESSION_* so a nested mare does not read them as config.
MARE_PEER_SOCKET This session’s peer socket, when it has one. mare peer send uses it.

The status plugin’s command (see Services and events) also receives MARE_STATE, MARE_MESSAGE, MARE_SESSION_ID, MARE_SESSION_PATH, MARE_CWD, MARE_SESSION_MODEL and MARE_PEER_SOCKET.

While the TUI is open, mare also sets SUDO_ASKPASS, MARE_ASKPASS_SOCK and MARE_ASKPASS_TOKEN for commands, so sudo password prompts reach the TUI’s masked input box instead of failing for lack of a terminal.