Skip to content
Jörg Thalheim edited this page May 9, 2018 · 3 revisions

Usually sudo will reset environment variables. However direnv provides an easy way to restore the important ones.

First whitelist your file for the root user:

$ sudo direnv allow

Then use the exec subcommand of direnv. In this example with want to run a python projects with sudo variables:

$ sudo direnv exec . python app.py