In debug mode, comments and empty lines almost appear as invalid syntax
See original GitHub issueI use Vue CLI service to run my project, which uses dotenv. While trying to debug something with Express that’s running in Vue’s (really Webpack’s) dev server, I set an environment variable DEBUG=express:router
.
I appreciate that none of this has anything to do with dotenv, but because I’m using a certain toolchain, and the minor issue I see is IMHO a dotenv issue, I hope you don’t mind that I am reporting the following issue here.
Because the DEBUG
variable is set (to anything, I guess), dotenv becomes verbose. I can live with that, it’s only at startup, and not a very big deal. So by extension, this issue is not a big one or fatal one.
As dotenv starts parsing my files, it prints this for every line that is either a comment or an empty line:
[dotenv][DEBUG] did not match key and value when parsing line 2: # this is a comment
While not technically incorrect, it comes across as if my file has a syntax error in it, even though the documentation states that comments like this are allowed, and I assume empty lines are too.
My suggestion to improve this would be that the parser not just detect key/value pairs, but also comments and empty lines, and only prints a debug message for lines that follow no known syntax.
Thank you.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:7 (4 by maintainers)
We agree with you. Use
v13.0.1
. It has fixed this up. It now ignores comments and empty lines in the debug output.https://github.com/motdotla/dotenv/blob/v13.0.1/CHANGELOG.md#1301-2022-01-16
Thank you for raising this @ronkorving. It’s a scenario we did not anticipate. We are going to overhaul the debug mode soon - and we will fix this then.