Skip to main content

Environment Variables

PySentry supports environment variables for configuration and debugging.

Configuration Variables​

VariableDescriptionExample
PYSENTRY_CONFIGOverride config file path (supports .pysentry.toml or pyproject.toml)PYSENTRY_CONFIG=/path/to/pyproject.toml
PYSENTRY_NO_CONFIGDisable all config file loadingPYSENTRY_NO_CONFIG=1

Examples​

Override Configuration File​

# Use a specific configuration file
PYSENTRY_CONFIG=/path/to/.pysentry.toml pysentry-rs

# Use pyproject.toml from a different location
PYSENTRY_CONFIG=/path/to/pyproject.toml pysentry-rs

Disable Configuration Files​

# Run with only CLI arguments, ignore all config files
PYSENTRY_NO_CONFIG=1 pysentry-rs --fail-on high

Color Control​

PySentry respects standard terminal color environment variables:

VariableDescription
NO_COLORDisable color output. Any value (including empty string) disables ANSI colors. See no-color.org
FORCE_COLORForce color output even when stdout is not a terminal

These variables are handled automatically when --color auto (the default). They have no effect when --color always or --color never is explicitly set.

RUST_LOG for Debugging​

For fine-grained logging control, use the RUST_LOG environment variable. When set, it takes precedence over -v flags.

Basic Usage​

# Enable debug logging for all pysentry modules
RUST_LOG=pysentry=debug pysentry-rs /path/to/project

# Enable trace logging for specific modules
RUST_LOG=pysentry::parsers=trace pysentry-rs /path/to/project

# Combine multiple module filters
RUST_LOG=pysentry=info,pysentry::dependency=debug pysentry-rs /path/to/project

Common Patterns​

# Debug dependency resolution
RUST_LOG=pysentry::dependency=debug pysentry-rs /path/to/project

# Debug vulnerability matching
RUST_LOG=pysentry::vulnerability=debug pysentry-rs /path/to/project

# Debug parser selection
RUST_LOG=pysentry::parsers=debug pysentry-rs /path/to/project

# Debug caching behavior
RUST_LOG=pysentry::cache=debug pysentry-rs /path/to/project

# Full trace output (very verbose)
RUST_LOG=pysentry=trace pysentry-rs /path/to/project

Use Cases​

RUST_LOG is useful for:

  • Debugging specific components without verbose output from others
  • CI/CD environments where you want consistent log levels
  • Troubleshooting issues with detailed module-specific logs
  • Performance analysis by tracing specific subsystems

Resolver Environment Variables​

When using external resolvers for requirements.txt, pyproject.toml, or Pipfile files, PySentry reads these environment variables for cache key differentiation. The resolvers themselves also read these variables from the environment when executed.

This ensures that different index configurations produce different cache entries, preventing incorrect resolution results when switching between package indexes.

UV Resolver​

VariableDescription
UV_PYTHONPython interpreter path
UV_INDEX_URLCustom PyPI index URL
UV_EXTRA_INDEX_URLExtra PyPI index URL
UV_PRERELEASEAllow prerelease versions

pip-tools Resolver​

VariableDescription
PIP_INDEX_URLCustom PyPI index URL
PIP_EXTRA_INDEX_URLExtra PyPI index URL
PIP_TRUSTED_HOSTTrusted host for pip
PIP_PREAllow prerelease versions

Platform-Specific Variables​

Cache Directory​

PySentry respects standard cache directory environment variables:

PlatformVariableDefault
LinuxXDG_CACHE_HOME~/.cache
macOS-~/Library/Caches
WindowsLOCALAPPDATA%LOCALAPPDATA%

Override with --cache-dir flag:

pysentry-rs --cache-dir /custom/cache/path