env-cmd icon indicating copy to clipboard operation
env-cmd copied to clipboard

Windows Git Bash + zsh without WSL

Open rafakwolf opened this issue 2 years ago • 1 comments

Hi folks, I know that it's likely an edge case, but any help would be great.

I'm using git bash on Windows 11

❯ git -v
git version 2.41.0.windows.1

and installed zsh following this tutorial: https://dev.to/equiman/zsh-on-windows-without-wsl-4ah9 and almost everything is working fine

I have the following scripts on my package.json

"load-api-env-vars": "./node_modules/.bin/env-cmd -f ./packages/project-api/.env",
"api:start": "yarn load-api-env-vars nx run project-api:serve"

looking into the env-cmd bin file:

case `uname` in
    *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac

however, when I ran uname here's the result:

❯ uname
MINGW64_NT-10.0-22621

and even adding something like that, it's not working

case `uname` in
    *MINGW64*) basedir=`cygpath -w "$basedir"`;;
esac

So I put a console.log to investigate a bit more:

❯ yarn load-api-env-vars
yarn run v1.22.19
$ ./node_modules/.bin/env-cmd -f ./packages/project-api/.env
getEnvVars options { envFile: undefined, rc: undefined, verbose: false }
Error: Failed to find .env file at default paths: [./.env,./.env.js,./.env.json]
    at getEnvFile (C:\Users\user\work\fwd\node_modules\env-cmd\dist\get-env-vars.js:59:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.EnvCmd (C:\Users\user\work\fwd\node_modules\env-cmd\dist\env-cmd.js:39:15)
    at async Object.CLI (C:\Users\user\work\fwd\node_modules\env-cmd\dist\env-cmd.js:19:16)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Looks like even specifying the "-f env-file-path", in the options it is still empty.

Thanks!

rafakwolf avatar Jun 28 '23 15:06 rafakwolf

I do believe this resulted from either one of two issues.

  1. The usage of commander and how I parsed out provided arguments was wonky/hacky. I have since fixed that on master and soon v11 by now utilizing the supported -- separator between env-cmd args and the actual command to run with args. This separator I think also provides better readability and clarity on the command line.

  2. I was not properly constructing paths between Windows/Unix pathing styles. I am now utilizing built-in node utils to help resolve/switch between windows/unix style pathing.

Feel free to give the current master a shot and see if that resolves your issues.

toddbluhm avatar Dec 04 '24 14:12 toddbluhm