[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--env-file flag collision for node 20 #131

Closed
keoz-simon opened this issue Mar 19, 2024 · 10 comments
Closed

--env-file flag collision for node 20 #131

keoz-simon opened this issue Mar 19, 2024 · 10 comments

Comments

@keoz-simon
Copy link

Hey! I'm trying to implement dotenvx to my TypeScript project.

This is my desired command:
dotenvx run --env-file=.env --env-file=.env.test --env-file=.env.test.local --overload ...

In case .env.test.local or any other --env-file option is not present, dotenvx fails. I think native fs error bubbles up. I'd suggest and need for my case an option, that it doesn't fail if a file is not present. I think it's not mandatory to let it fail. What do you think?

thanks!

@motdotla
Copy link
Contributor

i think you're right. it shouldn't fail. it should just warn. will patch up.

@motdotla
Copy link
Contributor

what version are you on? looks like this behavior is already correct - warns on missing file:

Screenshot 2024-03-19 at 10 42 44 AM

@simonhard
Copy link
simonhard commented Mar 19, 2024
CleanShot 2024-03-19 at 18 49 52@2x hm.. should be the same. It doesn't even logs any debug log but exits early with exit 9 sigkill.

btw: sorry, different github account, same person. The globally installed dotenvx is the same as in projects node_modules

@motdotla
Copy link
Contributor

what node version are you using here? maybe there is a flag collision i need to look into.

@simonhard
Copy link

@motdotla v20.11.1
Which one are you using? I could recheck with yours.
OS is macOS 14.3

@simonhard
Copy link
simonhard commented Mar 22, 2024

yes, that's the issue. node@18-latest works. node@20.11.1 doesn't.

@motdotla
Copy link
Contributor

we used --env-file because we like the principle of least surprise (keep in mind many devs use the binary rather than the npm install (in which case this is not an issue))

that said, to unblock you, use -f as the flag instead of --env-file. that should work.

i'll also reconsider the flag name.

@motdotla motdotla changed the title Don't fail on missing --env-file --env-file flag collision for node 20 Mar 22, 2024
@motdotla motdotla reopened this Mar 22, 2024
@simonhard
Copy link

If I didn't get you wrong: binary doesn't work too. But I'm totally with you using this flag name.

-f would be a good workaround. Maybe + warning in README.
nevertheless best solution would be no collision at all.
thanks for your work

@motdotla
Copy link
Contributor

binary should work, but not the node_modules/.bin/dotenvx since it's still dependent on the running node version.

the binary (or brew) installs can be done via:

brew install dotenvx/brew/dotenvx
or 
curl -fsS https://dotenvx.sh/ | sh

@motdotla
Copy link
Contributor

there is some chatter with the Node team that they will replace the error with a warning - which I hope and expect to see.

So until then, I'm adding this issue to a new FAQ:

https://github.com/dotenvx/dotenvx?tab=readme-ov-file#faq

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants