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.
- macOS
- Linux
- Windows
Switching Versions
How Homebrew versioning works
Homebrew provides two types of DCM formulas:
dcm: Always points to the latest version[email protected]: Installs a specific version (e.g.,[email protected])
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.
- Zsh / Bash
- Fish
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
function dcm-switch
set -l version $argv[1]
if test -z "$version"
echo "Usage: dcm-switch <version>"
echo "Example: dcm-switch 1.35.0"
echo ""
echo "📋 Installed versions:"
brew list --formula | grep -E '^dcm(@|$)'; or echo "No DCM versions installed"
return 1
end
echo "🔄 Switching DCM to version $version..."
# Unlink all DCM versions
brew unlink dcm 2>/dev/null
for f in (brew list --formula | grep '^dcm@')
brew unlink $f 2>/dev/null
end
# Install if needed, then link
if brew list --versions "dcm@$version" >/dev/null 2>&1
echo "📦 Version dcm@$version already installed"
else
echo "📥 Installing dcm@$version..."
brew tap CQLabs/dcm; and brew install "dcm@$version"
end
echo "🔗 Linking dcm@$version..."
brew link --overwrite --force "dcm@$version"
echo "✅ Done. Current DCM version:"
dcm --version; or echo "❌ DCM not in PATH"
end
function dcm-list
echo "📋 Installed versions:"
brew list --formula | grep -E '^dcm(@|$)'; or echo "No DCM versions installed"
echo ""
echo "🔗 Currently linked:"
dcm --version 2>/dev/null; or echo "None"
end
function dcm-latest
echo "🔄 Switching to latest DCM version..."
for f in (brew list --formula | grep '^dcm@')
brew unlink $f 2>/dev/null
end
brew tap CQLabs/dcm
brew upgrade dcm 2>/dev/null; or brew install dcm
brew link --overwrite --force dcm
echo "✅ Done. Current DCM version:"
dcm --version
end
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.
Switching Versions
APT supports installing specific versions. Version numbers include a build suffix (e.g., 1.35.0-1).
# List available versions
apt-cache madison dcm
# Install or downgrade to a specific version
sudo apt-get update
sudo apt-get install --allow-downgrades dcm=1.35.0-1
# Verify
dcm --version
Shell Helper Scripts
Add to your shell configuration for convenient version management.
- Zsh / Bash
- Fish
dcm_switch() {
local version=$1
if [[ -z "$version" ]]; then
echo "Usage: dcm-switch <version>"
echo "Example: dcm-switch 1.35.0"
echo ""
echo "📋 Available versions:"
apt-cache madison dcm | head -15
return 1
fi
# Append build number if missing
[[ "$version" =~ -[0-9]+$ ]] || version="${version}-1"
echo "🔄 Switching DCM to version $version..."
sudo apt-get update -qq
echo "📥 Installing dcm=$version..."
if sudo apt-get install -y --allow-downgrades "dcm=$version"; then
echo "✅ Done. Current DCM version:"
dcm --version
else
echo "❌ Failed to install dcm=$version"
return 1
fi
}
alias dcm-switch=dcm_switch
dcm_list() {
echo "📋 Available versions:"
apt-cache madison dcm | head -15
echo ""
echo "🔗 Currently installed:"
dcm --version 2>/dev/null || echo "DCM not installed"
}
alias dcm-list=dcm_list
dcm_latest() {
echo "🔄 Upgrading to latest DCM version..."
sudo apt-get update
sudo apt-get install -y dcm
echo "✅ Done. Current DCM version:"
dcm --version
}
alias dcm-latest=dcm_latest
function dcm-switch
set -l version $argv[1]
if test -z "$version"
echo "Usage: dcm-switch <version>"
echo "Example: dcm-switch 1.35.0"
echo ""
echo "📋 Available versions:"
apt-cache madison dcm | head -15
return 1
end
# Append build number if missing
string match -rq -- '-[0-9]+$' $version; or set version "$version-1"
echo "🔄 Switching DCM to version $version..."
sudo apt-get update -qq
echo "📥 Installing dcm=$version..."
if sudo apt-get install -y --allow-downgrades "dcm=$version"
echo "✅ Done. Current DCM version:"
dcm --version
else
echo "❌ Failed to install dcm=$version"
return 1
end
end
function dcm-list
echo "📋 Available versions:"
apt-cache madison dcm | head -15
echo ""
echo "🔗 Currently installed:"
dcm --version 2>/dev/null; or echo "DCM not installed"
end
function dcm-latest
echo "🔄 Upgrading to latest DCM version..."
sudo apt-get update
sudo apt-get install -y dcm
echo "✅ Done. Current DCM version:"
dcm --version
end
Usage:
dcm-switch 1.35.0 # Switch to specific version
dcm-list # Show available versions
dcm-latest # Upgrade to latest version
Here is an output of dcm-latest
$ dcm-latest
🔄 Upgrading to latest DCM version...
✅ Done. Current DCM version:
DCM version: 1.35.0
Direct Package Download
For versions not available in the repository, you can download and install DCM packages directly. See the Installation Guide - Direct Package Download for detailed instructions.
Troubleshooting
"Package dcm=X.Y.Z-1 has no installation candidate"
This error means APT's package cache doesn't have the requested version, either because the version doesn't exist or the package list is stale.
sudo apt-get update
apt-cache madison dcm # Check available versions
DCM not found after installation
Occurs when the system can't locate the DCM binary, usually due to PATH issues or incomplete installation. The binary may be installed in a non-standard location.
Check installation location with which dcm. Ensure /usr/bin is in your PATH.
Switching Versions
Chocolatey handles version switching with the --allow-downgrade flag (see Chocolatey Install and Upgrade documentation).
# Install or switch to a specific version
choco install dcm --version 1.35.0 --allow-downgrade -y
# List installed version
choco list dcm --local-only
# Upgrade to latest
choco upgrade dcm -y
# Verify
dcm --version
Shell Helper Scripts
Add to your PowerShell profile (notepad $PROFILE). See about_Functions and Write-Host documentation.
function dcm-switch {
param([string]$Version)
if (-not $Version) {
Write-Host "Usage: dcm-switch <version>" -ForegroundColor Yellow
Write-Host "Example: dcm-switch 1.35.0" -ForegroundColor Yellow
Write-Host ""
Write-Host "Installed:" -ForegroundColor Cyan
choco list dcm
return
}
Write-Host "Switching DCM to version $Version..." -ForegroundColor Cyan
choco install dcm --version $Version --allow-downgrade -y
if ($LASTEXITCODE -eq 0) {
Write-Host "Done. Current DCM version:" -ForegroundColor Green
dcm --version
}
else {
Write-Host "Failed to switch DCM version" -ForegroundColor Red
}
}
function dcm-list {
Write-Host "Installed:" -ForegroundColor Cyan
choco list dcm
Write-Host ""
Write-Host "Available versions:" -ForegroundColor Cyan
choco search dcm --all-versions | Select-Object -First 15
}
function dcm-latest {
Write-Host "Upgrading to latest DCM version..." -ForegroundColor Cyan
choco upgrade dcm -y
Write-Host "Done. Current DCM version:" -ForegroundColor Green
dcm --version
}
Command Prompt Batch File
For CMD users, create dcm-switch.bat in a directory in your PATH. See if command and echo command documentation.
@echo off
if "%~1"=="" (
echo Usage: dcm-switch ^<version^>
echo Example: dcm-switch 1.35.0
choco list dcm --local-only
exit /b 1
)
choco install dcm --version "%~1" --allow-downgrade -y
dcm --version
Usage:
dcm-switch 1.35.0 # Switch to specific version (CMD and PowerShell)
dcm-list # Show versions (PowerShell only)
dcm-latest # Upgrade to latest version (PowerShell only)
Here is an example of dcm-latest command output:
$ dcm-latest
Upgrading to latest DCM version...
Chocolatey v2.3.0
Upgrading the following packages: dcm
By upgrading, you accept licenses for the packages.
dcm is not installed. Installing...
Downloading package from source 'https://community.chocolatey.org/api/v2/'
dcm v1.35.0 [Approved]
dcm package files upgrade completed. Performing other installation steps.
Downloading dcm
from 'https://github.com/CQLabs/homebrew-dcm/releases/download/1.35.0/dcm-windows-release.zip'
Progress: 100% - Completed download of C:\Users\USERNAME\AppData\Local\Temp\chocolatey\dcm\1.35.0\dcm-windows-release.zip (8.6 MB).
Download of dcm-windows-release.zip (8.6 MB) completed.
Hashes match.
Extracting C:\Users\USERNAME\AppData\Local\Temp\chocolatey\dcm\1.35.0\dcm-windows-release.zip to C:\ProgramData\chocolatey\lib\dcm\tools...
C:\ProgramData\chocolatey\lib\dcm\tools
ShimGen has successfully created a shim for dcm.exe
ShimGen has successfully created a shim for ._dcm.exe
The upgrade of dcm was successful.
Deployed to 'C:\ProgramData\chocolatey\lib\dcm\tools'
Chocolatey upgraded 1/1 packages.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
Done. Current DCM version:
DCM version: 1.35.0
Troubleshooting
Version conflicts
Happens when Chocolatey has conflicting package metadata or corrupted installation state. A clean reinstall resolves package registry issues.
choco uninstall dcm -y
choco install dcm --version 1.35.0 -y
DCM not found
The system can't locate DCM because Chocolatey's bin directory (%ALLUSERSPROFILE%\chocolatey\bin) isn't in the system PATH or hasn't been refreshed after installation.
Verify with where dcm. If not found, either restart your terminal to refresh environment variables, run refreshenv (Chocolatey's built-in PATH refresh command), or manually add Chocolatey's bin directory to 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:
- Zsh / Bash
- Fish
- PowerShell
dcm_fvm() {
if [[ -d ".fvm/flutter_sdk" ]]; then
dcm --sdk-path=".fvm/flutter_sdk" "$@"
else
dcm "$@"
fi
}
alias dcm-fvm=dcm_fvm
function dcm-fvm
if test -d ".fvm/flutter_sdk"
dcm --sdk-path=".fvm/flutter_sdk" $argv
else
dcm $argv
end
end
function dcm-fvm {
if (Test-Path ".fvm\flutter_sdk") {
dcm --sdk-path=".fvm\flutter_sdk" @args
} else {
dcm @args
}
}
Usage:
- Zsh / Bash / Fish
- PowerShell
# 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
# Use dcm-fvm just like regular dcm commands
dcm-fvm --version
dcm-fvm analyze lib
dcm-fvm check-unused-code lib
## output
# PS> 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:
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.