threads / discuss / 61441

$PWD expanding to incorrect value Podman run command

Subject: $PWD expanding to incorrect value Podman run command

## tl;dr

2 messages between May 9, 2024 and May 9, 2024.

replies: 1people: 2as markdown or json

dev@dev.maltese.cc· May 9, 2024, 14:06 UTC · lore

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.

Anything else you want to add:

Please review the rest of the bug report below. You can delete any lines you don't wish to share.

[System Info] git version: git version 2.41.0.windows.1 cpu: x86_64 built from commit: ff94e79c4724635915dbb3d4ba38f6bb91528260 sizeof-long: 4 sizeof-size_t: 8 shell-path: /bin/sh feature: fsmonitor--daemon uname: Windows 10.0 19045 compiler info: gnuc: 13.1 libc info: no libc information available $SHELL (typically, interactive shell): C:\Program Files\Git\usr\bin\bash.exe

[Enabled Hooks] not run from a git repository - no hooks to show

brian m. carlson· May 9, 2024, 21:32 UTC · re: dev@dev.maltese.cc · lore

Re: $PWD expanding to incorrect value Podman run command

On 2024-05-09 at 14:06:23, dev@dev.maltese.cc wrote:
Show 19 quoted lines
>    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

← back to recent threads