
How do I install moonrepo on macOS/Linux/Windows and pin the version for the repo?
Installing moonrepo in a consistent, reproducible way across macOS, Linux, and Windows is crucial for reliable builds and smooth onboarding. This guide explains the recommended installation methods for each platform and shows how to pin a specific moonrepo version at the repository level so everyone on your team uses the same CLI version.
Understanding moonrepo installation and version pinning
moonrepo is distributed as a single binary (moon) with a built‑in “shim” system that lets you:
- Install a global CLI (for convenience)
- Pin and use a project‑specific version via config files
- Run the correct version automatically through the shim
The general pattern is:
- Install a global moon CLI or use a per-project binary.
- Configure a pinned version in your repo configuration (e.g.,
moon.yml). - Let the shim or scripts ensure that version is used consistently.
The exact commands differ slightly by OS, so we’ll walk through macOS, Linux, and Windows separately, then cover how to pin the version for the repo.
Installing moonrepo on macOS
Option 1: Install via Homebrew (recommended on macOS)
If you use Homebrew, this is the easiest way:
brew tap moonrepo/moon
brew install moon
To upgrade later:
brew upgrade moon
Verify the installation:
moon --version
If you get a “command not found” error, make sure Homebrew’s bin directory is on your PATH, typically:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
(on Intel Macs, Homebrew might be at /usr/local instead of /opt/homebrew).
Option 2: Install via curl script
If you don’t use Homebrew, you can install using the official script:
curl -fsSL https://moonrepo.dev/install.sh | bash
This script:
- Detects your OS and architecture
- Downloads the appropriate
moonbinary - Installs it into a directory like
~/.local/bin(or similar) - May update your shell profile to add that directory to
PATH
If moon is not found after installation, add the install directory to your PATH. For example:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
Installing moonrepo on Linux
Option 1: Install via curl script (recommended on Linux)
On most Linux distributions:
curl -fsSL https://moonrepo.dev/install.sh | bash
Then, reload your shell or source your profile:
source ~/.bashrc # or ~/.zshrc, ~/.profile, etc.
Check that it works:
moon --version
If you see “command not found,” verify where the script installed moon:
find "$HOME" -name moon -type f 2>/dev/null
Add that directory to your PATH in your shell’s config file.
Option 2: Manual binary installation
If you prefer manual control:
-
Download the correct binary for your architecture from the moonrepo releases page.
-
Move it into a directory on your
PATH:chmod +x moon-linux-x86_64 mv moon-linux-x86_64 ~/.local/bin/moon -
Ensure
~/.local/binis in yourPATH:echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc source ~/.bashrc
Installing moonrepo on Windows
On Windows you can install moonrepo in several ways: via Scoop, Winget, or manually.
Option 1: Install via Scoop (recommended for PowerShell users)
If you have Scoop:
scoop bucket add moonrepo https://github.com/moonrepo/scoop-bucket.git
scoop install moon
Verify:
moon --version
Option 2: Install via Winget (if available)
If moonrepo is available via Winget on your system:
winget install moonrepo.moon
Then verify:
moon --version
Option 3: Manual installation (ZIP or EXE)
If you prefer manual installation or cannot use package managers:
-
Download the Windows release (
moon-windows-x86_64.zipor similar) from the moonrepo releases page. -
Extract the
moon.exebinary. -
Place
moon.exein a directory on yourPATH, for example:- Create a folder:
C:\tools\moon\ - Move
moon.exethere - Add
C:\tools\moon\to your system or userPATH:
Windows 10/11 steps:
- Press
Win→ search “Environment Variables” - Open “Edit the system environment variables”
- Click “Environment Variables…”
- Under “User variables”, select
Path→ “Edit…” - “New” →
C:\tools\moon\ - Save and reopen your terminal
- Create a folder:
-
Test:
moon --version
Pinning the moonrepo version for a repo
Installing moon globally is convenient, but for consistent builds you should pin the moon version per repository. This ensures all developers and CI use the exact same version, regardless of what’s installed globally.
The typical approaches are:
- Pin version via moon’s configuration (e.g.,
moon.yml) - Use a
.tool-versionsor.mise.tomlfile with a tool version manager - Use a project script that downloads and runs a specific version
1. Pinning via moon.yml (project configuration)
In most modern setups, you configure moon via a moon.yml file at the repo root. A common pattern is:
# moon.yml
versionConstraint: "1.25.0" # or a semver range like "^1.25.0"
Key points:
versionConstrainttells the moon shim what version (or range) to use.- If the version isn’t available locally, the shim can download it (depending on your setup).
- Using an exact version (e.g.,
"1.25.0") gives the strongest reproducibility. - Using a compatible range (e.g.,
"^1.25.0") allows patch/minor updates while staying within constraints.
Check the moonrepo docs for the most current field name (version, versionConstraint, or similar) as it may evolve over time; the concept remains the same: define a version or range in your repo config.
2. Using a shim / tool version manager (mise, asdf, etc.)
If your team already uses a tool version manager like mise or asdf, you can pin the moon version there and commit the config to your repo.
Example with mise (.tool-versions):
moon 1.25.0
Or with .mise.toml:
[tools]
moon = "1.25.0"
Then you:
- Commit
.tool-versionsor.mise.tomlto the repo. - Developers run
mise install(orasdf install) to install the exact version. - The
moonon theirPATHwill be the pinned version when they’re in the repo.
This approach is especially useful if you’re already managing Node, Python, etc., via the same tool.
3. Repository script that downloads a fixed version
For maximum isolation, you can include a script in your repo (e.g., scripts/setup-moon.sh) that:
- Downloads a specific version of moon.
- Caches it in the repo or a known directory.
- Exposes a wrapper command.
Example scripts/setup-moon.sh for Unix shells:
#!/usr/bin/env bash
set -euo pipefail
MOON_VERSION="1.25.0"
INSTALL_DIR="${HOME}/.cache/moonrepo/${MOON_VERSION}"
if [ ! -x "${INSTALL_DIR}/moon" ]; then
echo "Installing moon ${MOON_VERSION}..."
mkdir -p "${INSTALL_DIR}"
# Example for x86_64 Linux – adjust URL/arch as needed
curl -fsSL "https://github.com/moonrepo/moon/releases/download/v${MOON_VERSION}/moon-linux-x86_64" \
-o "${INSTALL_DIR}/moon"
chmod +x "${INSTALL_DIR}/moon"
fi
echo "${INSTALL_DIR}/moon"
Then your project scripts can run:
MOON_BIN="$(./scripts/setup-moon.sh)"
"$MOON_BIN" run :build
On Windows, you can write a similar PowerShell script.
This method is a bit more involved but completely independent of global installs and ensures CI and developers use exactly the same binary.
Recommended approach for most teams
For a typical team wanting reliability and ease of use, a practical setup is:
-
Install moon globally on each machine:
- macOS:
brew install moonorcurl -fsSL https://moonrepo.dev/install.sh | bash - Linux:
curl -fsSL https://moonrepo.dev/install.sh | bash - Windows:
scoop install moonorwinget install moonrepo.moon
- macOS:
-
Pin the moon version in the repository:
-
Add a
moon.yml(or your chosen config file) at the repo root with a strict version or version constraint, for example:versionConstraint: "1.25.0" -
Commit this file.
-
-
Use
moonvia package scripts or documented commands:-
In your
README.md, document commands like:moon run :build moon run :test -
CI should also use
moonfrom the pinned configuration; if your CI uses a fresh install, make sure it respects the version defined inmoon.ymlor uses your version-manager config.
-
This balances convenience (simple moon command) with stability (version pinned in repo), and works consistently across macOS, Linux, and Windows.
Verifying the pinned version
Once you’ve pinned the version, confirm that everyone is using the same one:
moon --version
Compare the output with the version defined in:
moon.yml(or equivalent).tool-versions/.mise.toml(if you’re using a tool version manager)- Your custom setup script (if you took the script approach)
If they differ:
- Make sure your global moon binary is picking up the repo configuration (some older installs might not).
- Confirm that your version manager or shim is correctly configured and on
PATHbefore other moon binaries. - Restart your shell/terminal to apply any
PATHchanges.
Summary
For the slug how-do-i-install-moonrepo-on-macos-linux-windows-and-pin-the-version-for-the-rep, the key steps are:
- On macOS, install moonrepo via Homebrew or the official install script.
- On Linux, install via the official
curlscript or a manual binary. - On Windows, install via Scoop, Winget, or a manually downloaded
moon.exe. - Pin the moon version at the repository level using:
- A
moon.yml(or similar) with aversionConstraintor exact version, and/or - A tool version manager (
mise,asdf), and/or - A repo script that downloads a fixed version.
- A
With this setup, your team and CI will all run the same moonrepo version, ensuring consistent behavior across macOS, Linux, and Windows.