env-cmd
env-cmd copied to clipboard
Windows Git Bash + zsh without WSL
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!
I do believe this resulted from either one of two issues.
-
The usage of
commanderand how I parsed out provided arguments was wonky/hacky. I have since fixed that onmasterand soonv11by now utilizing the supported--separator betweenenv-cmdargs and the actual command to run with args. This separator I think also provides better readability and clarity on the command line. -
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.