env-debug
Environment Debugging
Troubleshoot PATH, permissions, env vars, and configuration issues.
"Command Not Found"
# Check if command exists
which node
which python
command -v node
type node
# Check PATH
echo $PATH
echo $PATH | tr ':' '\n' # One per line
# Find where a binary lives
which -a python # All matches in PATH
whereis python # Binary, source, and man pages
# Common fixes
export PATH="/usr/local/bin:$PATH" # Prepend
export PATH="$HOME/.local/bin:$PATH" # User binaries
export PATH="$HOME/.cargo/bin:$PATH" # Rust
export PATH="$HOME/go/bin:$PATH" # Go
export PATH="$HOME/.nvm/versions/node/v20.0.0/bin:$PATH" # nvm
# Make permanent - add to shell config:
# ~/.bashrc (bash), ~/.zshrc (zsh), ~/.profile (login shell)
Shell Configuration
# Which shell am I using?
echo $SHELL
echo $0
# Config file load order:
# bash login: /etc/profile → ~/.bash_profile → ~/.bashrc
# bash non-login: ~/.bashrc
# zsh login: ~/.zprofile → ~/.zshrc
# zsh non-login: ~/.zshrc
# Reload config
source ~/.zshrc
source ~/.bashrc
# Check if interactive/login
[[ $- == *i* ]] && echo "Interactive" || echo "Non-interactive"
shopt -q login_shell && echo "Login" || echo "Non-login" # bash
[[ -o login ]] && echo "Login" || echo "Non-login" # zsh
Environment Variables
# View all
env
printenv
# View specific
echo $NODE_ENV
printenv NODE_ENV
# Set for current session
export API_KEY="abc123"
export NODE_ENV=production
# Set for single command
NODE_ENV=test npm test
DATABASE_URL=postgres://localhost/test python manage.py migrate
# Unset
unset API_KEY
# Check if set
[ -z "$API_KEY" ] && echo "NOT SET" || echo "SET: $API_KEY"
# .env file loading
# Node.js: dotenv, or node --env-file=.env app.js (Node 20.6+)
# Python: python-dotenv
# Shell: source .env or export $(cat .env | xargs)
Permission Issues
# Check file permissions
ls -la /path/to/file
# Permission format: drwxrwxrwx
# d = directory, r = read, w = write, x = execute
# [owner][group][others]
# Make executable
chmod +x script.sh
chmod 755 script.sh # rwxr-xr-x
# Fix npm global permissions
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH="$HOME/.npm-global/bin:$PATH"
# Fix SSH key permissions
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub
chmod 644 ~/.ssh/config
# Check who owns a file
ls -la /usr/local/bin/node
# Fix ownership
sudo chown -R $(whoami) /usr/local/lib/node_modules
Port Issues
# What's using a port?
lsof -i :3000 # macOS/Linux
ss -tlnp | grep 3000 # Linux
netstat -tlnp | grep 3000 # Linux
# Kill process on port
lsof -ti :3000 | xargs kill -9 # macOS/Linux
fuser -k 3000/tcp # Linux
# Check if port is available
nc -z localhost 3000 && echo "IN USE" || echo "FREE"
Node.js Issues
# Multiple Node versions?
which -a node
node --version
# nvm issues
nvm ls # List installed versions
nvm use 20 # Switch version
nvm alias default 20 # Set default
nvm current # Current version
# npm cache issues
npm cache clean --force
rm -rf node_modules package-lock.json && npm install
# Global packages location
npm root -g
npm list -g --depth=0
# npx not finding package
npx --yes package-name # Force install
npm exec -- package-name # Alternative
Python Issues
# Multiple Python versions?
which -a python
which -a python3
python --version
python3 --version
# Virtual environment active?
echo $VIRTUAL_ENV
# Wrong pip?
which pip
pip --version # Shows which Python it's linked to
python -m pip --version # Use specific Python's pip
# Module not found?
python -c "import sys; print('\n'.join(sys.path))"
python -c "import package; print(package.__file__)"
# pyenv issues
pyenv versions
pyenv which python
pyenv shell 3.12.1
DNS / Network Issues
# DNS resolution
nslookup example.com
dig example.com
host example.com
# Test connectivity
ping -c 3 example.com
curl -v https://example.com
# Check proxy settings
echo $HTTP_PROXY
echo $HTTPS_PROXY
echo $NO_PROXY
# SSL certificate issues
openssl s_client -connect example.com:443
# Test specific port
nc -zv example.com 443
curl -v telnet://example.com:443
Docker Issues
# Docker daemon running?
docker info
# Permission denied?
sudo usermod -aG docker $USER
# Then log out and back in
# DNS issues in container
docker run --dns 8.8.8.8 myimage
# Can't connect to container?
docker inspect <container> | grep IPAddress
docker port <container>
Disk Space
# Check disk usage
df -h
# Find large files/dirs
du -sh *
du -sh * | sort -rh | head -20
# Node.js specific
du -sh node_modules/
npx npkill # Interactive node_modules cleaner
# Docker specific
docker system df
docker system prune -a --volumes
Quick Diagnostic Script
#!/bin/bash
echo "=== System ==="
uname -a
echo ""
echo "=== Shell ==="
echo "$SHELL ($0)"
echo ""
echo "=== PATH ==="
echo $PATH | tr ':' '\n'
echo ""
echo "=== Key Tools ==="
for cmd in node npm python python3 pip git docker; do
printf "%-10s" "$cmd:"
command -v $cmd 2>/dev/null && $cmd --version 2>/dev/null | head -1 || echo "NOT FOUND"
done
echo ""
echo "=== Env Vars ==="
for var in NODE_ENV VIRTUAL_ENV HOME USER SHELL TERM; do
printf "%-15s %s\n" "$var:" "${!var:-NOT SET}"
done
Reference
For tool-specific troubleshooting: references/troubleshooting.md
More from 1mangesh1/dev-skills-collection
curl-http
HTTP request construction and API testing with curl and HTTPie. Use when user asks to "test API", "make HTTP request", "curl POST", "send request", "test endpoint", "debug API", "upload file", "check response time", "set auth header", "basic auth with curl", "send JSON", "test webhook", "check status code", "follow redirects", "rate limit testing", "measure API latency", "stress test endpoint", "mock API response", or any HTTP calls from the command line.
28database-indexing
Database indexing internals, index type selection, query plan analysis, and write-overhead tradeoffs across PostgreSQL, MySQL, and MongoDB. Use when user asks to "optimize queries", "create indexes", "fix slow queries", "read EXPLAIN output", "reduce query time", "index strategy", "database performance", "composite index", "covering index", "partial index", "index bloat", "unused indexes", or needs help diagnosing and resolving database performance problems.
13testing-strategies
Testing strategies, patterns, and methodologies across the full testing spectrum. Use when asked about unit tests, integration tests, e2e tests, test pyramid, mocking, test doubles, TDD, property-based testing, snapshot testing, test coverage, mutation testing, contract testing, performance testing, test data management, CI/CD testing, flaky tests, test anti-patterns, test organization, test isolation, test fixtures, test parameterization, or any testing strategy, approach, or methodology.
10secret-scanner
This skill should be used when the user asks to "scan for secrets", "find API keys", "detect credentials", "check for hardcoded passwords", "find leaked tokens", "scan for sensitive keys", "check git history for secrets", "audit repository for credentials", or mentions secret detection, credential scanning, API key exposure, token leakage, password detection, or security key auditing.
10terraform
Terraform infrastructure as code for provisioning, modules, state management, and workspaces. Use when user asks to "create infrastructure", "write Terraform", "manage state", "create module", "import resource", "plan changes", or any IaC tasks.
10kubernetes
Kubernetes and kubectl mastery for deployments, services, pods, debugging, and cluster management. Use when user asks to "deploy to k8s", "create deployment", "debug pod", "kubectl commands", "scale service", "check pod logs", "create ingress", or any Kubernetes tasks.
10