Troubleshooting CLI Issues
Resolve common Safeguard CLI problems and errors
Troubleshooting CLI Issues
This guide helps you diagnose and resolve common issues with the Safeguard CLI.
Enable Debug Mode
First, enable debug logging to get more information:
# Via environment variable
export SAFEGUARD_DEBUG=true
safeguard sbom generate --source .
# Or with --verbose flag
safeguard sbom generate --source . --verboseAuthentication Issues
"Authentication failed" or "Invalid API key"
Symptoms:
- Error message: "Authentication failed"
- HTTP 401 errors
Solutions:
- Verify your API key is correct:
safeguard auth status- Re-authenticate:
safeguard auth logout
safeguard auth login- Check environment variable:
echo $SAFEGUARD_API_KEY- Ensure API key has required permissions in Settings → API Keys
"Token expired"
Solution:
safeguard auth refresh
# Or re-login
safeguard auth loginSSO Authentication Issues
If browser-based login fails:
- Try the manual token flow:
safeguard auth login --manual- Copy the URL and open in browser manually
- After authentication, paste the token back
Network Issues
"Connection refused" or "Network error"
Solutions:
- Check internet connectivity:
curl -I https://api.safeguard.sh/auth/- Configure proxy if behind corporate firewall:
export HTTP_PROXY=http://proxy.example.com:8080
export HTTPS_PROXY=http://proxy.example.com:8080- Check firewall rules allow outbound HTTPS (port 443)
"Certificate error" or "SSL handshake failed"
Solutions:
- Point the CLI at a custom CA bundle:
export SSL_CERT_FILE=/path/to/corporate-ca.crt- Update system CA certificates — the CLI uses the system trust store, so installing the certificate there fixes it for every tool at once:
# Ubuntu/Debian
sudo update-ca-certificates
# macOS
security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain /path/to/cert.crt- If neither works, contact support with the
output of
safeguard --versionand the full error.
Do not reach for a flag that turns certificate verification off. Trusting your
corporate CA — either in the system trust store or via SSL_CERT_FILE above —
solves the same problem without accepting any certificate from anyone.
Timeout Errors
Solutions:
- Increase timeout:
safeguard config set api.timeout 600-
Check for large projects that may need more time
-
Try scanning specific subdirectories instead of entire repository
Scanning Issues
"No dependencies found"
Possible causes:
- No manifest files in the directory
- Manifest files not recognized
- Wrong directory specified
Solutions:
- Verify manifest files exist:
ls -la package.json requirements.txt pom.xml go.mod Cargo.toml- Check you're in the correct directory:
pwd
safeguard sbom generate --source $(pwd)- Specify manifest file directly:
safeguard sbom generate --source . --manifest package.json"Unsupported package manager"
Solution: Check the support matrix for supported package managers.
Incomplete SBOM (Missing Dependencies)
Solutions:
- Install dependencies first:
# Node.js
npm install
# Python
pip install -r requirements.txt
# Go
go mod download- Include lock files:
# Ensure lock files exist
ls -la package-lock.json yarn.lock Pipfile.lock- Include development dependencies:
safeguard sbom generate --source . --include-dev"Out of memory" Error
Solutions:
- Scan subdirectories separately for monorepos:
safeguard sbom generate --source ./packages/app1
safeguard sbom generate --source ./packages/app2- Exclude unnecessary directories:
safeguard sbom generate --source . --ignore "test/**" --ignore "docs/**"Container Scanning Issues
"Image not found"
Solutions:
- Verify image exists:
docker images | grep myimage- Pull the image first:
docker pull myimage:latest
safeguard scan --image myimage:latest- Use full image reference:
safeguard scan --image docker.io/library/nginx:latest"Registry authentication failed"
Solutions:
- Login to registry first:
docker login myregistry.azurecr.io- Provide credentials:
safeguard scan --image myregistry.azurecr.io/app:v1 \
--registry-user $USERNAME \
--registry-password $PASSWORD- Configure registry in config file:
registries:
myregistry.azurecr.io:
username: ${REGISTRY_USER}
password: ${REGISTRY_PASSWORD}Policy/Gate Issues
"Policy not found"
Solutions:
- List available policies:
safeguard policy list- Use correct policy name:
safeguard gate check --source . --policy "Production Policy"- Create the policy in the web UI if it doesn't exist
Gate Failing Unexpectedly
Solutions:
- Check detailed results:
safeguard gate check --source . --verbose-
Review policy configuration in web UI
-
Check for approved exceptions:
safeguard gate check --source . --allow-exceptionsOutput Issues
"Permission denied" When Writing Output
Solutions:
- Check directory permissions:
ls -la ./sbom/
mkdir -p ./sbom && chmod 755 ./sbom- Specify a different output location:
safeguard sbom generate --source . --output ~/sbom/output.jsonMalformed Output
Solutions:
- Specify format explicitly:
safeguard sbom generate --source . --format cyclonedx-json- Check for console output interference:
safeguard sbom generate --source . --quiet --output sbom.jsonInstallation Issues
"Command not found: safeguard"
Solutions:
- Find every copy on your PATH:
which -a safeguardGet-Command safeguard -All- If more than one appears, the first wins. An old build under
~/go/binshadowing the installed one is the usual cause — check what each reports:
safeguard --version- If none appears, the install directory is not on your PATH. Open a new shell first (the Windows installer adds its directory to the user PATH, which existing shells do not pick up), then reinstall if it is still missing:
curl -fsSL https://cli.safeguard.sh/install | bash"syft binary not found" on a fresh install
Symptoms:
- A scan fails immediately on a machine where the CLI was just installed
Cause:
The CLI downloads its scanner toolchain the first time it needs it. A freshly installed binary has no scanners yet.
Solution:
Open the interactive terminal once and let first-run setup finish:
safeguardsafeguard update refreshes the vulnerability databases of scanners you
already have — it does not install missing ones. If a directory scan warns and
returns nothing on a new machine, the scanner database has not been populated
yet; run safeguard update after the first interactive run.
Getting More Help
Collect Diagnostic Information
safeguard diagnostics > diagnostics.txtThis collects:
- CLI version
- OS and architecture
- Configuration (with secrets redacted)
- Recent log entries
Contact Support
If issues persist:
-
Email hi@safeguard.sh with:
- Diagnostic output
- Error messages
- Steps to reproduce
-
Include relevant log files from
~/.safeguard/logs/
Reset Everything
As a last resort, reset the CLI completely:
# Remove local state: session, logs, history
rm -rf ~/.sg
# Reinstall over the top
curl -fsSL https://cli.safeguard.sh/install | bashRemove-Item "$env:USERPROFILE\.sg" -Recurse -Force
irm https://cli.safeguard.sh/install.ps1 | iexThen open the terminal and sign in again:
safeguardType /login, then /doctor to confirm health and connectivity.