Skip to main content

Managing DCM Versions

This guide covers switching between DCM versions and provides shell helper scripts to simplify the process. For initial installation, see the Installation Guide.

Switching Versions

How Homebrew versioning works

Homebrew provides two types of DCM formulas:

Only one version can be linked (active) at a time. Linking creates symlinks in /opt/homebrew/bin (Apple Silicon) or /usr/local/bin (Intel) that point to the active version.

# List all available versions
brew search /cqlabs/dcm

# Install a specific version
brew install [email protected]

# Unlink current version and link the new one
brew unlink dcm
brew link [email protected] --overwrite

# Verify
dcm --version

List installed DCM versions:

brew list --formula | grep -E '^dcm(@|$)'

# Result
# dcm
# [email protected]
# [email protected]
# [email protected]

Unlink all installed versions at once:

brew unlink dcm
brew list --formula | grep '^dcm@' | xargs -n1 brew unlink

Shell Helper Scripts

Add to your shell configuration for convenient version management.

~/.zshrc or ~/.bashrc
dcm_switch() {
local version=$1
if [[ -z "$version" ]]; then
echo "Usage: dcm-switch <version>"
echo "Example: dcm-switch 1.35.0"
echo ""
echo "📋 Installed versions:"
brew list --formula | grep -E '^dcm(@|$)' || echo "No DCM versions installed"
return 1
fi

echo "🔄 Switching DCM to version $version..."

# Unlink all DCM versions
brew unlink dcm 2>/dev/null
brew list --formula | grep '^dcm@' | xargs -I {} brew unlink {} 2>/dev/null

# Install if needed, then link
if brew list --versions "dcm@$version" >/dev/null 2>&1; then
echo "📦 Version dcm@$version already installed"
else
echo "📥 Installing dcm@$version..."
brew tap CQLabs/dcm && brew install "dcm@$version"
fi

echo "🔗 Linking dcm@$version..."
brew link --overwrite --force "dcm@$version"

echo "✅ Done. Current DCM version:"
dcm --version || echo "❌ DCM not in PATH"
}
alias dcm-switch=dcm_switch

dcm_list() {
echo "📋 Installed versions:"
brew list --formula | grep -E '^dcm(@|$)' || echo "No DCM versions installed"
echo ""
echo "🔗 Currently linked:"
dcm --version 2>/dev/null || echo "None"
}
alias dcm-list=dcm_list

dcm_latest() {
echo "🔄 Switching to latest DCM version..."
brew list --formula | grep '^dcm@' | xargs -I {} brew unlink {} 2>/dev/null
brew tap CQLabs/dcm
brew upgrade dcm 2>/dev/null || brew install dcm
brew link --overwrite --force dcm
echo "✅ Done. Current DCM version:"
dcm --version
}
alias dcm-latest=dcm_latest

Usage:

dcm-switch 1.35.0   # Switch to specific version
dcm-list # Show installed versions
dcm-latest # Upgrade to latest version

Here is an output example for dcm-latest

$ dcm-latest
🔄 Switching to latest DCM version...
Unlinking /opt/homebrew/Cellar/[email protected]/1.19.2... 0 symlinks removed.
Unlinking /opt/homebrew/Cellar/[email protected]/1.21.0... 0 symlinks removed.
Unlinking /opt/homebrew/Cellar/[email protected]/1.25.0... 0 symlinks removed.
Unlinking /opt/homebrew/Cellar/[email protected]/1.33.0... 1 symlinks removed.
Linking /opt/homebrew/Cellar/dcm/1.35.0... 1 symlinks created.

✅ Done. Current DCM version:
DCM version: 1.35.0

Troubleshooting

"No available formula with the name [email protected]"

This occurs when Homebrew doesn't have the DCM tap configured or the tap cache is outdated. Homebrew needs to know where to find versioned DCM formulas.

brew tap CQLabs/dcm
brew install [email protected]

"Could not symlink" errors

Happens when another DCM version already has symlinks in place. Homebrew won't overwrite existing symlinks by default to prevent conflicts.

brew link [email protected] --overwrite

Version conflicts after switching

Occurs when multiple DCM versions are partially linked, often after failed switch attempts. This creates conflicting symlinks in the bin directory.

# Unlink all versions and start fresh
brew unlink dcm
for formula in $(brew list --formula | grep '^dcm@'); do brew unlink $formula; done
brew link --overwrite [email protected]

DCM not found after switching

The system can't locate DCM because Homebrew's bin directory isn't in your shell's PATH. This typically happens with fresh Homebrew installations or custom shell configurations.

Ensure /opt/homebrew/bin (Apple Silicon) or /usr/local/bin (Intel) is in your PATH.

Using DCM with FVM

Automatic Detection

DCM automatically detects the .fvm/flutter_sdk symlink in your project directory. No configuration is required in most cases, simply run DCM commands as usual:

dcm analyze lib

If it fails to locate the SDK, refer to this page for the list of all places used to locate the SDK.

Manual Configuration (If Needed)

If automatic detection fails, configure DCM explicitly:

Use CLI flag

dcm analyze --sdk-path=.fvm/flutter_sdk lib

Or Environment variable

export DCM_SDK_PATH=.fvm/flutter_sdk
dcm analyze lib

Shell Wrapper for FVM Projects

Since DCM automatically detects FVM, these wrappers are only needed if automatic detection fails in your environment:

~/.zshrc or ~/.bashrc
dcm_fvm() {
if [[ -d ".fvm/flutter_sdk" ]]; then
dcm --sdk-path=".fvm/flutter_sdk" "$@"
else
dcm "$@"
fi
}
alias dcm-fvm=dcm_fvm

Usage:

# Use dcm-fvm just like regular dcm commands
dcm-fvm --version
dcm-fvm analyze lib
dcm-fvm check-unused-code lib

## output
# $ dcm-fvm --version
# DCM version: 1.35.0

Troubleshooting FVM Issues

If DCM reports SDK issues, verify the FVM symlink exists:

# Check if the symlink exists and is valid
ls -la .fvm/flutter_sdk

# Test DCM with explicit SDK path
dcm analyze --sdk-path=.fvm/flutter_sdk lib

If the symlink is missing, run fvm use to recreate it. See FVM troubleshooting for FVM-specific issues.

Team Version Consistency

To ensure all team members use compatible versions, add a dcm_global.yaml file to your project root:

dcm_global.yaml
version: '>=1.35.0 <2.0.0'

DCM will warn users if their installed version doesn't match this constraint. See Global Configuration for details.