git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: BUG: git bash / python interaction with absolute paths as environment variables in Windows

From
LWLeland Weathers <leland@lcweathers.net>
Date
Dec 7, 2021, 13:10 UTC
Message-ID
<CAHeq4YwfbcwfzxjmiWJUYxtCAn9wf9AW5kNJ8+ps8dAYOn7ZAA@mail.gmail.com>
In-Reply-To
<CAPig+cQSEUguKRfCBLoDfLvH5orAX-_KZ+pZE=h4u2x3N_yNzQ@mail.gmail.com>
Eric, thanks for the pointer. Got it working as expected now.
On Mon, Dec 6, 2021 at 9:16 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 34 quoted lines
>
> On Mon, Dec 6, 2021 at 10:01 PM Leland Weathers <leland@lcweathers.net> 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/
Previous: Eric SunshineNext: Johannes Schindelin
Message 3 of 4 in “BUG: git bash / python interaction with absolute paths as environment variables in Windows”
  1. Leland WeathersDec 7, 2021
  2. Eric SunshineDec 7, 2021
  3. Leland WeathersDec 7, 2021
  4. Johannes SchindelinDec 7, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.