From: Leland Weathers <leland@lcweathers.net>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: Git List <git@vger.kernel.org>
Subject: Re: BUG: git bash / python interaction with absolute paths as environment variables in Windows
Date: Tue, 7 Dec 2021 07:10:35 -0600 [thread overview]
Message-ID: <CAHeq4YwfbcwfzxjmiWJUYxtCAn9wf9AW5kNJ8+ps8dAYOn7ZAA@mail.gmail.com> (raw)
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:
>
> 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/
next prev parent reply other threads:[~2021-12-07 13:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-07 3:00 BUG: git bash / python interaction with absolute paths as environment variables in Windows Leland Weathers
2021-12-07 3:15 ` Eric Sunshine
2021-12-07 13:10 ` Leland Weathers [this message]
2021-12-07 21:39 ` Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAHeq4YwfbcwfzxjmiWJUYxtCAn9wf9AW5kNJ8+ps8dAYOn7ZAA@mail.gmail.com \
--to=leland@lcweathers.net \
--cc=git@vger.kernel.org \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).