Common issues and solutions when using Twin.
- Connection Issues
- Sync Issues
- Configuration Issues
- Git Integration Issues
- Permission Errors
- Performance Issues
Error: Error: Cannot connect to SSH remote 'myserver'
Solutions:
-
Verify SSH config exists:
grep -A 5 "^Host myserver" ~/.ssh/config
-
Test SSH connection directly:
ssh myserver exit # Should connect without password
-
Check SSH config format:
Host myserver HostName example.com User deploy # Note: SSH config is indented with spaces or tabs -
Verify network connectivity:
ping example.com
See SSH Setup Guide for detailed SSH configuration.
Error: Connection times out when syncing
Solutions:
-
Increase SSH timeout:
# In ~/.ssh/config Host myserver ConnectTimeout 30 ServerAliveInterval 60 -
Test connection speed:
time ssh myserver exit
-
Check firewall/network:
# Test if port is open nc -zv example.com 22
Problem: Files exist locally but don't appear on remote
Diagnosis:
# Run with dry-run to see what would sync
twin -e "-av --dry-run" myserver
# Check what Twin would transferCommon causes:
-
Files are excluded:
# Check rsync flags for --exclude cat .twin.myserver.json | grep rsync_flags
-
Files are newer on remote:
# Force transfer regardless of timestamp twin -e "-av --ignore-times" myserver
-
Permission issues (see Permission Errors)
Problem: Transfer interrupts midway
Solution:
# Enable partial transfer resume
twin -e "-avuP" myserver
# -P = --partial --progressProblem: Files disappear after sync
Cause: Using --delete flag
Check:
cat .twin.myserver.json | grep rsync_flags
# Look for --deleteFix:
# Remove --delete flag
twin -e "-avu --progress" myserverProblem: Twin doesn't remember remote path or flags
Check:
-
Verify config file exists:
ls -la .twin.*.json -
Check file permissions:
ls -la .twin.myserver.json # Should be writable by user -
Verify twin-config is executable:
which twin-config ls -la $(which twin-config)
Problem: Error reading config file
Solution:
# Check config format
cat .twin.myserver.json
# Should be valid JSON
# If corrupted, remove and re-pair
rm .twin.myserver.json
twin myserver /remote/pathProblem: Wrong remote path used
Cause: Multiple .twin.*.json files in directory
Check:
ls -la .twin.*.jsonSolution: Each remote should have one config file. Remove extras:
rm .twin.old-server.jsonError: Warning: Git remote 'target' already exists on local machine
Solutions:
-
Provide alternate name when prompted:
Enter alternate name (or press Enter to skip): staging -
Remove existing remote:
git remote remove target twin -g myserver # Force re-setup -
Use custom name from start:
twin --git-local-name custom-name myserver
Problem: Expected git remote setup didn't happen
Check:
-
Both directories are git repos:
ls -la .git # Local ssh myserver "ls -la /remote/path/.git" # Remote
-
Setup wasn't skipped:
# Check if -G flag was used # Check config cat .twin.myserver.json | grep git_integration
-
Setup already completed:
# Check if setup_complete is true cat .twin.myserver.json | grep setup_complete
Force git setup:
twin -g myserverProblem: git fetch target fails after Twin setup
Check:
-
Verify remote exists:
git remote -v
-
Test SSH connection:
ssh myserver exit -
Verify remote path is git repo:
ssh myserver "cd /remote/path && git status" -
Check remote URL:
git remote get-url target # Should be: myserver:/remote/path
See Git Integration Guide for more details.
Error: rsync: mkdir "/remote/path" failed: Permission denied
Solutions:
-
Check remote directory permissions:
ssh myserver "ls -ld /remote/path" -
Verify SSH user has write access:
ssh myserver "touch /remote/path/test.txt && rm /remote/path/test.txt" -
Create directory with correct ownership:
ssh myserver "sudo mkdir -p /remote/path && sudo chown $USER /remote/path"
Problem: Synced files have wrong owner on remote
Solution: Use rsync's ownership preservation (may require sudo):
# Preserve ownership (may need sudo on remote)
twin -e "-avugo" myserver
# Or set specific owner on remote
ssh myserver "sudo chown -R webuser:webgroup /remote/path"Problem: Syncs take too long
Diagnose:
# Add verbose and progress flags
twin -e "-avuP" myserver
# Watch transfer speedSolutions:
-
Enable compression (slow network):
twin -e "-avuz" myserver -
Disable compression (fast network):
twin -e "-avu" myserver -
Use faster checksum (if using checksums):
# Switch to timestamp (faster) twin -e "-avu" myserver
-
Limit bandwidth (if saturating network):
twin -e "-avu --bwlimit=1000" myserver # 1000 KB/s
Problem: CPU maxed during sync
Cause: Compression is CPU-intensive
Solution:
# Disable compression
twin -e "-avu" myserver
# Or lower compression level
twin -e "-avuz --compress-level=3" myserverProblem: Thousands of small files sync slowly
Solutions:
-
Exclude unnecessary files:
twin -e '-avu --exclude=node_modules/ --exclude=.git/' myserver -
Use checksum for fewer checks (paradoxically faster for many unchanged files):
twin -e "-av --checksum" myserver
Cause: No remote name provided
Fix:
twin myserver # Not: twinCause: Local directory path invalid
Fix:
cd ~/correct/path
twin myserverCause: rsync not installed on local or remote
Fix:
# On local machine
sudo apt install rsync # Debian/Ubuntu
brew install rsync # macOS
# On remote
ssh myserver "sudo apt install rsync"Cause: Python 3 not available for twin-config
Fix:
# Install Python 3
sudo apt install python3 # Debian/Ubuntu
brew install python3 # macOS
# Verify
python3 --versionIf you encounter an issue not covered here:
-
Check verbose output:
twin -e "-avvv" myserver # Maximum verbosity
-
Check logs:
# SSH connection logs ssh -vvv myserver exit # Rsync detailed log twin -e "-avvv --log-file=/tmp/rsync.log" myserver cat /tmp/rsync.log
-
Report issue: GitHub Issues
- Include Twin version
- Include error message
- Include relevant config (redact sensitive data)