Infisical / infisical

♾ Infisical is the open-source secret management platform: Sync secrets across your team/infrastructure, prevent secret leaks, and manage internal PKI
https://infisical.com
Other
12.93k stars 667 forks source link

infisical CLI: Path incorrect with Git bash / windows #1595

Open Khaaz opened 3 months ago

Khaaz commented 3 months ago

Describe the bug

Discussed in this thread on slack: https://infisical-users.slack.com/archives/C04BSBMQAQ7/p1709161491917939

I am on windows, I use cmder which use git bash it seems.
I can reproduce this issue with git bash directly, but I can't reproduce it on WSL for instance.

In the terminal, I have no issue at all, it works perfectly. However when I put the same command in a SH script it doesn't.
I am correctly logged (I logged in with infisical login).

After a lot of debugging, here what I found:

When I use the command like this:

infisical export --path="/account" --env="dev"

It in fact replaces the / by the path to the executable C:/Program Files/Git. So it tries to request a secret with the path: C:/Program Files/Git/account

I have to "escape" the / with a second / like: //

infisical export --path="//account" --env="dev"

And that actually works

To Reproduce

Expected behavior

It should behave the same way as it does on UNIX.

Screenshots

The script ran through cmder and git bash, with the command being exactly:

infisical export --path="/account" --env="dev"

image image

Platform you are having the issue on:

WIndows, with git bash / cmder.

Additional context

My current workaround is:

#!/usr/bin/env sh

PACKAGE_ROOT=$PWD
PACKAGE_NAME=$(basename "$PACKAGE_ROOT")

ENV="dev"
PREFIX=""

case $(uname | tr '[:upper:]' '[:lower:]') in
  msys*)
    PREFIX=//
    ;;
  *)
    PREFIX=/
    ;;
esac

infisical export --path="$PREFIX$PACKAGE_NAME" --env=$ENV

Although it's clearly not optimum.

akhilmhdh commented 2 months ago

Hey @Khaaz i don't think this is an Infisical specific issue rather something with the tool and platform