This guide will help you set up the development environment for template-bevy using various methods.
Choose one of the following setup methods based on your preference:
- Local Development: Rust 1.70+, platform-specific dependencies
- Docker: Docker 20.10+ and Docker Compose (optional)
- Nix: Nix package manager with flakes enabled
- Codespaces: GitHub account (no local setup required)
The fastest way to get started depends on your environment:
# Local development (with dynamic linking for faster builds)
cargo run --features dev
# Docker
docker compose up
# Nix (with flakes)
nix develop
cargo run
# GitHub Codespaces
# Just open the repository in Codespaces - everything is preconfigured!-
Install Rust (if not already installed):
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source $HOME/.cargo/env
-
Install platform-specific dependencies:
-
Ubuntu/Debian:
sudo apt-get update sudo apt-get install pkg-config libx11-dev libasound2-dev libudev-dev libxkbcommon-x11-0
-
Fedora:
sudo dnf install pkgconfig alsa-lib-devel systemd-devel
-
macOS: No additional dependencies needed.
-
Windows: No additional dependencies needed.
-
-
Clone and build:
git clone https://github.com/pnstack/template-bevy.git cd template-bevy cargo build --release -
Run the game:
# Development build (faster compilation) cargo run --features dev # Release build (optimized) cargo run --release
Install additional development tools:
# Format checker
rustup component add rustfmt
# Linter
rustup component add clippy
# IDE support
rustup component add rust-analyzer-
Build the Docker image:
docker build -t template-bevy:latest . -
Run the container:
docker run --rm template-bevy:latest --help
Nix provides reproducible development environments across different systems.
-
Enable flakes (if not already enabled):
mkdir -p ~/.config/nix echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.conf
-
Enter development environment:
nix develop
This provides:
- Rust toolchain with rust-analyzer
- All build dependencies
- Development tools
-
Build the project:
nix build
-
Run the game:
nix run
If you prefer not to use flakes:
nix-shellThis provides the same development environment using shell.nix.
The easiest way to get started with zero local setup.
-
Open in Codespaces:
- Navigate to the repository on GitHub
- Click "Code" → "Codespaces" → "Create codespace on main"
- Wait for the environment to build (first time only)
-
Start developing:
- All tools are pre-installed
- VS Code with Rust extensions ready
- Project automatically builds on creation
If you have Docker and VS Code locally:
-
Install prerequisites:
- Docker Desktop
- VS Code
- "Dev Containers" extension for VS Code
-
Open in container:
- Open the repository in VS Code
- Press
F1→ "Dev Containers: Reopen in Container" - Wait for container to build
-
Start developing:
- Integrated terminal has all tools
- Extensions auto-installed
- Same environment as Codespaces
cargo build --features devcargo build --releaseThe binary will be in target/release/template-bevy.
cargo checkcargo testcargo test test_namecargo test -- --nocapturecargo test --test integration_testscargo fmtcargo fmt --checkcargo clippycargo clippy -- -D warningsSolution: Install ALSA development libraries
# Ubuntu/Debian
sudo apt-get install libasound2-dev
# Fedora
sudo dnf install alsa-lib-develSolution: Install udev development libraries
# Ubuntu/Debian
sudo apt-get install libudev-dev
# Fedora
sudo dnf install systemd-develSolution: Use dynamic linking during development
cargo run --features devSolution: This is normal for the first build - Bevy has many dependencies. Subsequent builds are much faster due to incremental compilation.
Tips for faster iteration:
- Use
cargo checkinstead ofcargo buildwhen just checking for errors - Use
--features devfor dynamic linking - Consider using
cargo watchfor automatic rebuilds
The game supports the following environment variables:
RUST_BACKTRACE: Set to1orfullfor detailed error tracesRUST_LOG: Set log level (e.g.,debug,info,warn,error)
Example:
export RUST_BACKTRACE=1
export RUST_LOG=info
cargo runAfter setting up your environment:
- Read the README.md for usage instructions
- Explore the examples/ directory
- Check the tests/ directory for test examples
- Review the src/ directory structure for the game architecture
If you encounter issues:
- Check this guide's Common Issues section
- Search existing GitHub Issues
- Open a new issue with:
- Your setup method (Local/Docker/Nix/Codespaces)
- Operating system and version
- Rust version (
rustc --version) - Complete error message
- Steps to reproduce
See README.md for contribution guidelines.