Failed to parse any RC file style
parse-rc-file.js seems contain only import() based logic and JSON files, so no default behavior
.env
SOME_ID=idididi
.env-cmdrc
{
"elma365": {
"SOME_ID": "idididi"
}
}
Noone works with 11 version
Error: Failed to find environments: [console.log(process.env)] for .rc file at path: ./.env-cmdrc
Error [ParseError]: Failed to parse .rc file at path: ....\project\.env.
Thanks for trying out v11! I am a little confused by what you're asking. Are you asking for .env to be a default fallback if the environment you are looking for in .env-cmdrc does not exist?
Please share the command with flags you are using when getting those errors.
I believe only a .rc file or .env will work; you cannot combine them both. However, I have never tested that scenario.
simple
env-cmd --file .env node -e "console.log(process.env)"
for example
Ah, I see your issue now. What is happening is that the -e in that command is being interpreted/captured by env-cmd, not node. You have to run commands like this now env-cmd --file .env -- node -e "console.log(process.env)"
env-cmd is capturing the -e flag and using it. The -- tells env-cmd to take everything after -- and treat it as one command to execute (rather than parsing it).
This is intended behavior. You will notice the README has been updated to reflect that change. I will make a PR to add that to the CHANGELOG as well.
@toddbluhm the same result
Seems PS wrapper issue
Windows CMD: works: env-cmd --file .env -- node -e "console.log(process.env)"
Windows PS: Error: env-cmd --file .env -- node -e "console.log(process.env)" Error [ParseError]: Failed to parse .rc file
Works: env-cmd --file .env -- -- node -e "console.log(process.env)"
Ah, interesting. I will have to boot into bootcamp, test it out on powershell, and do some research as to what is going on. Good catch, atleast there is a workaround for now.
I had the same/similar issue since upgrading (on linux). I had to change my command from env-cmd -e development yarn build to env-cmd -e development -- yarn build
@will-osborne so this is intended behavior. The -- will be used to separate env-cmd flags from the command (and flags) that will be executed by env-cmd.
The double dashes (-- --) is not intended behavior.
The PR linked to this issue will fix the changelog documentation issue stating the requirement to use --.
However the double dashes (-- --) in powershell will need additional investigation.
@Delagen So I got into my bootcamp side and did some research on this issue. It appears to be a powershell specific issue and only when executing env-cmd as a global (ie env-cmd -f .env -- node -e "console.log(process.env)"). When running as a global, the first -- gets eaten by powershell (never passed as an arg to env-cmd), hence the need for the second -- which is passed to env-cmd and why -- -- causes env-cmd to function properly.
However, the following does work under powershell:
node ./node_modules/env-cmd/bin/env-cmd.js -f .env -- node -e "console.log(process.env)"
and in package.json:
{
"scripts": {
"test": "env-cmd -f .env -- node -e \"console.log(process.env)\""
}
}
Since the first -- for global execution is eaten by powershell, I can't really fix this issue except to move away from -- completely which is not really a viable option at this time. I will try to get a note added to the docs about this powershell specific issue though so other people don't get hung up on this.
I run env-cmd local package via npm run. May be also issue in wrapper installed by npm, it's different for cmd and ps. So you can close this issue if it depend on platform and cannot be fixed in library.