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.
Start with doctor
safeguard doctor checks the environment, sign-in, tools and policy and
prints what is wrong, most important first. It changes nothing:
safeguard doctorFor more detail while a scan runs, add --verbose:
safeguard scan --dir . --verboseEvery run also writes a structured log to ~/.sg/logs/safeguard.log.
Authentication Issues
"Not authenticated" or HTTP 401
- See who you are signed in as, and whether the token has expired:
safeguard whoami- Sign in again.
--forcere-authorizes even when a session exists, which is also how you switch accounts:
safeguard logout
safeguard login --forceThe CLI does not read an API key from the environment. A machine is
authorized by signing in with /login or safeguard login.
Browser sign-in does not open or does not finish
Use the device code by hand:
safeguard login --no-browserThe CLI prints a verification URL and a short code. Open the URL on any device, enter the code, approve, and the CLI picks up the session.
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:
- Scan a subdirectory instead of the whole repository:
safeguard scan --dir ./services/api- Skip transitive resolution, which makes network calls for every
dependency, unless you need it (it is off unless you pass
--resolve-transitive).
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 scan --dir "$(pwd)""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"Out of memory" Error
Solutions:
- Scan subdirectories separately for monorepos:
safeguard scan --dir ./packages/app1
safeguard scan --dir ./packages/app2Container 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-username "$USERNAME" \
--registry-password "$PASSWORD"Policy and gate issues
The CLI has no policy or gate command. Policies and gates are defined and evaluated in the platform, on the scans it runs and the results the runner uploads. See Policies & gates for how to see why a gate failed and how exceptions are approved.
Output Issues
"Permission denied" When Writing Output
Write somewhere you own:
safeguard scan --dir . --output ~/safeguard-resultsJSON on stdout is mixed with messages
Commands write machine-readable JSON to stdout and every notice and log line to stderr, so redirect stdout alone:
safeguard detect --format json > detect.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 --version
safeguard doctor > doctor.txtContact support
Raise it from the CLI, which files it on the same queue as the product's Help & Feedback sheet:
safeguard support bug "what you ran, what you expected, what happened"Or email hi@safeguard.sh with the doctor output,
the error and the steps to reproduce. The log file is
~/.sg/logs/safeguard.log.
Reset Everything
As a last resort, reset the CLI completely:
# Sign out and remove the deployment config
safeguard logout --yes
safeguard config reset --yes
# Remove local state: logs, history, sign-in token
rm -rf ~/.sg ~/.scanner
# Reinstall over the top
curl -fsSL https://cli.safeguard.sh/install | bashRemove-Item "$env:USERPROFILE\.sg", "$env:USERPROFILE\.scanner" -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.