moon sync command will synchronize the entire workspace and all projects by running configured sync operations. This ensures that all projects are in a consistent state and have their dependencies and tooling properly set up.
How it works
Themoon sync command performs the following operations:
- Builds action graph - Creates a graph of all sync operations needed
- Syncs workspace - Runs workspace-level sync operations
- Syncs all projects - Runs project-level sync operations for every project
- Executes pipeline - Runs all sync actions in topological order
- Reports success - Displays confirmation when sync is complete
- Installing or updating dependencies
- Generating configuration files
- Setting up toolchains
- Running setup hooks
- Updating lockfiles
Arguments
This command takes no arguments.Options
Inherits global options from overview:--cache <mode>- The mode for cache operations.--color- Force colored output.--concurrency,-c- Maximum number of threads to utilize.--log <level>- The lowest log level to output.--quiet,-q- Hide all non-important terminal output.
Examples
Basic sync
Synchronize the workspace and all projects:Sync with verbose logging
Sync without cache
Force fresh sync operations:Quiet sync
Minimal output:When to run sync
You should runmoon sync when:
After cloning a repository
When first setting up a workspace:After pulling changes
When dependencies or configuration may have changed:After modifying configuration
When you’ve changed workspace or project configuration:After adding dependencies
When you’ve added new dependencies to projects:In CI environments
Themoon ci command automatically runs sync operations, but you can run it explicitly:
Automatic syncing
In certain scenarios, moon will automatically run sync operations:- CI mode - When running
moon ci, workspace sync always runs - First run - On initial workspace setup
- Configuration changes - When configuration files are modified
Sync operations by tool
Different tools and platforms may perform different sync operations:Node.js / npm / yarn / pnpm
- Install dependencies from
package.json - Update lockfiles
- Link workspace packages
- Generate
node_modulesstructure
Rust / Cargo
- Install dependencies from
Cargo.toml - Update
Cargo.lock - Build workspace metadata
Python / pip / poetry
- Install dependencies from
requirements.txtorpyproject.toml - Update lockfiles
- Set up virtual environments
Go modules
- Download dependencies from
go.mod - Update
go.sum - Tidy module dependencies
Configuration
Sync behavior is configured through:projectsin.moon/workspace.*toolsin.moon/workspace.*nodesettings in.moon/toolchain.*- Project-specific configurations in
moon.*
Comparison with other commands
| Command | Syncs workspace | Syncs projects | Runs tasks |
|---|---|---|---|
moon sync | Yes | All | No |
moon ci | Yes | No | Yes |
moon run | No | No | Yes |