Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: dev@dev.maltese.cc
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: $PWD expanding to incorrect value Podman run command
Date: Thu, 9 May 2024 21:32:32 +0000	[thread overview]
Message-ID: <Zj1A8MsBRejNm_IF@tapette.crustytoothpaste.net> (raw)
In-Reply-To: <21209940.11022921.1715263583414@email.ionos.com>

[-- Attachment #1: Type: text/plain, Size: 2471 bytes --]

On 2024-05-09 at 14:06:23, dev@dev.maltese.cc wrote:
>    Thank you for filling out a Git bug report!
>    Please answer the following questions to help us understand your issue.
>     
>    What did you do before the bug happened? (Steps to reproduce your issue)
>    Installed podman and executed: "$ podman run -p 8081:80 -v
>    $PWD:/usr/share/nginx/html nginx"
>     
>    What did you expect to happen? (Expected behavior)
>    Expected the nginx image to run and map the current directory to the
>    '/usr/share/nginx/html' directory.
>     
>    What happened instead? (Actual behavior)
>    Received the error "Error: invalid container path "\\Program
>    Files\\Git\\usr\\share\\nginx\\html", must be an absolute path".
>     
>    What's different between what you expected and what actually happened?
>    I expected the docker $PWD (or ${PWD} or $(pwd) or $HOME) to expand to the
>    actual working directory, but it seems to expand to the directory of the
>    gitbash executable.

This isn't really a Git bug; it's more of a difference with how the
MSYS2 runtime shipped with Git for Windows works.  Note that the Git
project doesn't ship binaries or any software other than Git itself; Git
for Windows is the distributor of that and can be reached at
https://github.com/git-for-windows/git.

However, the reason you're seeing this is because most programs on
Windows don't accept the Unix-style paths that MSYS2 and Git Bash
provide, so to placate them, Git Bash converts paths that start with a
slash into Windows-style paths.  The root directory for Git Bash is the
Git installation directory, so when you write `/usr/share/nginx/html`,
Git Bash turns that into `C:\Program Files\Git\usr\share\nginx\html`.
The `$PWD` is not necessarily related here, although it may undergo the
same expansion.

If you don't want that behaviour, then you can use a double slash (e.g.,
`//usr/share/nginx/html`), or you can set `MSYS_NO_PATHCONV=1`, like so:

  MSYS_NO_PATHCONV=1podman run -p 8081:80 -v $PWD:/usr/share/nginx/html nginx

Note that you probably _do_ want `$PWD` to undergo expansion with MSYS,
though, so you may want to do this instead (untested):

  MSYS_NO_PATHCONV=1podman run -p 8081:80 -v "$(cygpath -w "$PWD"):/usr/share/nginx/html" nginx

If you have more questions about this, I'd reach out to the Git for
Windows folks.
-- 
brian m. carlson (they/them or he/him)
Toronto, Ontario, CA

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

      reply	other threads:[~2024-05-09 21:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-09 14:06 $PWD expanding to incorrect value Podman run command dev
2024-05-09 21:32 ` brian m. carlson [this message]

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=Zj1A8MsBRejNm_IF@tapette.crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=dev@dev.maltese.cc \
    --cc=git@vger.kernel.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).