Skip to main content

A utility for validating paths in environment variables and modifying them safely

Project description


A utility for validating paths in environment variables and modifying them safely.


  • Python 3


You can install path-diag via pip:

pip3 install path-diag


Diagnose environment variable problems

Check if $PATH contains any invalid paths:

$ pathdiag

$PATH is the default variable to check.

You can specify another variable. For example:

$ pathdiag --var PYTHONPATH

You can also specify an increased verbosity which will also print the paths that are successfully checked:

$ pathdiag -v
✓ /usr/local/bin
✓ /usr/bin
✓ /bin
✓ /usr/sbin
✓ /sbin

Safely append/prepend paths to environment variables

You can use the bash functions in order to take advantage of this features by adding the following line on top of your .bashrc/.zshrc file:

source /usr/local/bin/

Then you can use the safe_append/safe_prepend functions. For example:

safe_append "/usr/local/Cellar/node/7.4.0/bin"
safe_prepend "/usr/local/opt/python/libexec/bin"

This will add /usr/local/Cellar/node/7.4.0/bin at the end of $PATH if this path passes the validation checks, and will also add /usr/local/opt/python/libexec/bin at the beginning of $PATH, again if no errors are identified.


All contributions are welcomed. Make sure your code passes flake8 checks and that is auto-formatted using black

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for path-diag, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size path_diag-0.0.1-py3.6.egg (8.0 kB) File type Egg Python version 3.6 Upload date Hashes View
Filename, size path_diag-0.0.1-py3-none-any.whl (5.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size path-diag-0.0.1.tar.gz (4.4 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page