Eric, thanks for the pointer. Got it working as expected now. On Mon, Dec 6, 2021 at 9:16 PM Eric Sunshine <sunshine@xxxxxxxxxxxxxx> wrote: > > On Mon, Dec 6, 2021 at 10:01 PM Leland Weathers <leland@xxxxxxxxxxxxxx> wrote: > > Issue: Using Git Bash for Windows (2.34.1-64) and Python 3.9.9, a git > > path is incorrectly prepended to environment variables in Python code. > > > > $ echo $TEST_DIR_BROKEN > > /foo/bar > > $ echo $TEST_DIR_WORKING > > foo/bar > > $ python foobar.py > > environ: C:/Users/Leland/AppData/Local/Programs/Git/foo/bar > > environ: foo/bar > > > > Is there anything else I'm missing on why the same Python script would > > read environment variables differently than what is read from Git Bash > > itself or why the exact same Python code reads the environment > > variable correctly when run from a command prompt and not in Git Bash? > > > > In both cases I am using the same Python virtual environment. Other > > environment variables (e.g. non-absolute directory paths) appear to be > > read correctly. I'm assuming that this is a git issue given the > > This is probably not specific to Git, but rather a "feature" of MSYS2, > which Git for Windows happens to employ for its Bash shell. When > invoking Windows commands from within MSYS2, command-line arguments > and environment variables on the Unix side which appear to be paths > will be converted to Windows paths for the sake of the native Windows > program (since it won't know anything about the Unix paths coming out > of the MSYS2 environment). > > This behavior is documented at [1]; in particular, see the > "Environment Variables" section. > > [1]: https://www.msys2.org/docs/filesystem-paths/