Skip to content
Skills Library
Programming · Tool integration

xmake-env-vars

/xmake-env-vars

Use when configuring xmake via environment variables — `XMAKE_PROGRAM_DIR`/`XMAKE_PROGRAM_FILE` (local source debug), `XMAKE_GLOBALDIR`/`XMAKE_CONFIGDIR` (config locations), `XMAKE_COLORTERM`/`XMAKE_PROFILE`, `XMAKE_RCFILES` (global defaults), `XMAKE_ROOT`, and how to list/inspect them with `xmake show -l envs`.

Licence
Apache-2.0
Last repository change
24.08.2026

Assessment and security

98/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene13 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
1
Deprecation

No signals detected. Repository changed on 24.08.2026, without references to retired models or APIs.

Licence

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

What it does and when to use it

Use when configuring xmake via environment variables — `XMAKE_PROGRAM_DIR`/`XMAKE_PROGRAM_FILE` (local source debug), `XMAKE_GLOBALDIR`/`XMAKE_CONFIGDIR` (config locations), `XMAKE_COLORTERM`/`XMAKE_PROFILE`, `XMAKE_RCFILES` (global defaults), `XMAKE_ROOT`, and how to list/inspect them with `xmake show -l envs`.

Original author description

Use when configuring xmake via environment variables — `XMAKE_PROGRAM_DIR`/`XMAKE_PROGRAM_FILE` (local source debug), `XMAKE_GLOBALDIR`/`XMAKE_CONFIGDIR` (config locations), `XMAKE_COLORTERM`/`XMAKE_PROFILE`, `XMAKE_RCFILES` (global defaults), `XMAKE_ROOT`, and how to list/inspect them with `xmake show -l envs`.

How it works

  1. List them all
  2. Reference
  3. Precedence rules
  4. Inspecting from scripts
  5. Common uses
  6. Pitfalls
  7. When to branch out
Original SKILL.md headings · 147 lines, 689 words
SKILL.md preview
---
name: xmake-env-vars
description: Use when configuring xmake via environment variables — `XMAKE_PROGRAM_DIR`/`XMAKE_PROGRAM_FILE` (local source debug), `XMAKE_GLOBALDIR`/`XMAKE_CONFIGDIR` (config locations), `XMAKE_COLORTERM`/`XMAKE_PROFILE`, `XMAKE_RCFILES` (global defaults), `XMAKE_ROOT`, and how to list/inspect them with `xmake show -l envs`.
---

# Xmake Environment Variables

Xmake reads a handful of `XMAKE_*` environment variables to relocate config, enable profiling, load user-wide defaults, and more. They take precedence over the matching `xmake g` global setting when both are present.

## List them all

```bash
xmake show -l envs
```

Shows every recognized variable, its description, and the currently resolved value on your system.

## Reference

### Paths

| Variable | Purpose | Default |
| --- | --- | --- |
| `XMAKE_PROGRAM_DIR` | Where xmake's Lua scripts live | xmake install dir |
| `XMAKE_PROGRAM_FILE` | Which `xmake` binary to use | resolved from PATH |
| `XMAKE_GLOBALDIR` | Root for `xmake g` global config (creates `.xmake/` inside) | `~` |
| `XMAKE_CONFIGDIR` | Where per-project `.xmake/` cache goes | project dir |
| `XMAKE_TMPDIR` | Temp scratch | `/tmp/.xmake` / `%TEMP%\.xmake` |
| `XMAKE_RAMDIR` | Optional ramdisk for temp files — fastest | unset |
| `XMAKE_PKG_INSTALLDIR` | Package install root | `$XMAKE_GLOBALDIR/.xmake/packages` |
| `XMAKE_PKG_CACHEDIR` | Package cache dir | `$XMAKE_GLOBALDIR/.xmake/cache` |
| `XMAKE_LOGFILE` | Log everything xmake does to this file | unset |

Typical uses:

```bash
# Use a local source checkout of xmake (developing xmake itself — see xmake-dev skill)
export XMAKE_PROGRAM_DIR=/path/to/xmake/xmake
export XMAKE_PROGRAM_FILE=/path/to/xmake/core/build/xmake

# Keep project .xmake out of the repo root
export XMAKE_CONFIGDIR=/tmp/myproject-xmake

# Put packages on a fast disk
export XMAKE_PKG_INSTALLDIR=/mnt/fast/xmake-packages
export XMAKE_PKG_CACHEDIR=/mnt/fast/xmake-cache

# Ram-disk temp for crazy-fast configures
export XMAKE_RAMDIR=/dev/shm/xmake
```

### Output / behavior

| Variable | Values | Purpose |
| --- | --- | --- |
| `XMAKE_COLORTERM` | `nocolor` / `color8` / `color256` / `truecolor` | Force color mode |
| `XMAKE_PROFILE` | `stuck` / `trace` / `perf:call` / `perf:tag` / `perf:process` | Profiling / stuck debug — see `xmake-troubleshooting` |
| `XMAKE_ROOT` | `y` | Allow running as root (off by default — unsafe) |
| `XMAKE_LOGFILE` | path | Mirror xmake output to a log file |
| `XMAKE_THEME` | theme name | Equivalent to `xmake g --theme=...` |

### User-wide defaults: `XMAKE_RCFILES`

Xmake loads a user-specified "rc" file before any `xmake.lua` is parsed. Use it for global toolchains, default repos, company-wide policies — anything you want every project on the machine to pick up.

```bash
# Unix: colon-separated multiple files
export XMAKE_RCFILES=~/.xmake/xmakerc.lua:/etc/xmake/xmakerc.lua

# Windows: semicolon-separated
set XMAKE_RCFILES=C:\xmake\xmakerc.lua;D:\proj\xmakerc.lua
```

Example `~/.xmake/xmakerc.lua`:

```lua
-- Always enable debug+release modes
add_rules("mode.debug", "mode.release")

-- Company-wide package repo
add_repositories("mycompany https://github.com/mycompany/xmake-repo.git")

-- Pin a preferred toolchain
toolchain("mygcc")
    set_kind("standalone")
    set_toolset("cc", "gcc-11")
    set_toolset("cxx", "g++-11")
toolchain_end()
```

Precedence: rc files load before the project `xmake.lua`, so the project can still override anything they set.

## Precedence rules

For settings that have both an env var and a `xmake g` equivalent:

1. Env var (highest)
2. `xmake g` global config
3. Project-level `xmake f` config
4. Built-in default

So `XMAKE_COLORTERM=nocolor xmake` always disables color, regardless of `xmake g --theme`.

## Inspecting from scripts

From inside a script-domain hook:

```lua
on_load(function (target)
    local configdir = os.getenv("XMAKE_CONFIGDIR")
    if configdir then
        print("using config dir %s", configdir)
    end
end)
```

`os.getenv` is one of the few env-reading APIs allowed in the description domain as read-only — fine for conditional config flags.

## Common uses

```bash
# CI: disable color, log everything
XMAKE_COLORTERM=nocolor XMAKE_LOGFILE=build.log xmake

# Debug a stuck build
XMAKE_PROFILE=stuck xmake f -c

# Profile configure
XMAKE_PROFILE=perf:process xmake f -c

# Dev xmake from a checkout
source scripts/srcenv.profile         # sets XMAKE_PROGRAM_DIR + _FILE

# Cache-aware CI
XMAKE_PKG_CACHEDIR=$HOME/ci-cache/xmake-pkg xmake
```

## Pitfalls

- **Forgetting `XMAKE_PROGRAM_DIR` after a dev test.** Leaves `xmake` pointing at a stale checkout. `unset XMAKE_PROGRAM_DIR` to restore.
- **`XMAKE_RCFILES` breaks projects.** A rc file that force-adds rules/toolchains can clash with a project that configures its own. Scope rc files carefully; prefer description-only.
- **`XMAKE_ROOT=y`.** Works, but running as root is dangerous — prefer a regular user.
- **Env var precedence over `xmake g`.** If `xmake g --color256` seems ignored, check whether `XMAKE_COLORTERM` is exported.
- **Logfile silently filling the disk.** `XMAKE_LOGFILE` appends; rotate it yourself if enabled permanently.

## When to branch out

- Developing xmake source and switching `XMAKE_PROGRAM_*` → `xmake-dev`
- Profiling / stuck debug (`XMAKE_PROFILE`) → `xmake-troubleshooting`
- Color / theme knobs → `xmake-theme`, `xmake-color-output`

Versions

The database has no other skills named xmake-env-vars.

Database snapshot: 13.11.2026 · package version b7791c34c5a6 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 95xmake-commands
    Use when invoking Xmake from the command line — configuring, building, running, cleaning, installing, packing, or inspecting a project. Covers the common flags for `xmake f`, `xmake`, `xmake run`, `xmake install`, `xmake pack`, and friends.
  • 100xmake-unit-tests
    Use when running or adding **xmake's own** unit tests — working in the `xmake-io/xmake` source tree, invoking `xmake l tests/run.lua [testname]`, writing new test files under `tests/`, and integrating with `srcenv.profile`. Not for testing *your own* project — that's `xmake-tests`.
  • 100svelte-env-vars-check
    This skill should be used when the user says "check svelte env vars", "check environment variables", "validate env vars", "check env var patterns", "audit environment variables", "audit env vars", "check SvelteKit env", "svelte env check", or any phrase asking to audit or…
  • 100env-setup-wizard
    Set up environment variables, .env files, and configuration management. Use when configuring environment variables, creating .env files, or managing app configuration.
  • 100env-validator
    Validates .env files against code references and manifests for missing vars, type mismatches, insecure defaults, and unused entries. Triggers on: "validate env file", "check environment variables", "missing env vars", "check .env", "dotenv validation". NOT for secret scanning, use repo-sentinel.
  • 100content-sdk-site-setup-and-env
    Site and environment configuration for a Content SDK app: sitecore.config.ts, environment variables, default site and language, personalize and analytics settings. Use when configuring the app or env vars. Not proxy or tracking code.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.