-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
Closed
Labels
dotenvIssues and PRs related to .env file parsingIssues and PRs related to .env file parsing
Description
Version
v22.11.0
Platform
Linux abu 4.4.0-22621-Microsoft #3672-Microsoft Fri Jan 01 08:00:00 PST 2016 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
Ubuntu-22.04
What steps will reproduce the bug?
$ cat testenv # the next line is an empty line EMPTY_LINE='empty line' # the next line contains spaces SPACES_LINE='spaces line' # the next line contains tabs TAB_LINE='tab line' $ hexdump -C testenv 00000000 23 20 74 68 65 20 6e 65 78 74 20 6c 69 6e 65 20 |# the next line | 00000010 69 73 20 61 6e 20 65 6d 70 74 79 20 6c 69 6e 65 |is an empty line| 00000020 0a 0a 45 4d 50 54 59 5f 4c 49 4e 45 3d 27 65 6d |..EMPTY_LINE='em| 00000030 70 74 79 20 6c 69 6e 65 27 0a 23 20 74 68 65 20 |pty line'.# the | 00000040 6e 65 78 74 20 6c 69 6e 65 20 63 6f 6e 74 61 69 |next line contai| 00000050 6e 73 20 73 70 61 63 65 73 0a 20 20 20 0a 53 50 |ns spaces. .SP| 00000060 41 43 45 53 5f 4c 49 4e 45 3d 27 73 70 61 63 65 |ACES_LINE='space| 00000070 73 20 6c 69 6e 65 27 0a 23 20 74 68 65 20 6e 65 |s line'.# the ne| 00000080 78 74 20 6c 69 6e 65 20 63 6f 6e 74 61 69 6e 73 |xt line contains| 00000090 20 74 61 62 73 0a 09 09 0a 54 41 42 5f 4c 49 4e | tabs....TAB_LIN| 000000a0 45 3d 27 74 61 62 20 6c 69 6e 65 27 0a |E='tab line'.| 000000ad $ node --env-file=testenv -e 'console.log(`EMPTY_LINE: ${process.env.EMPTY_LINE}\nSPACES_LINE: ${process.env.SPACE_LINE}\nTAB_LINE: ${process.env.TAB_LINE}`);' EMPTY_LINE: empty line SPACES_LINE: undefined TAB_LINE: undefined $
How often does it reproduce? Is there a required condition?
Always happens. If the env file has a 'blank' line containing space(s) or tab(s), the environment variable defined on the next line will not be loaded at runtime.
What is the expected behavior? Why is that the expected behavior?
It is expected that blank lines (empty, spaces, tabs, whitespace) will be ignored when process the env file.
What do you see instead?
'blank' lines containing whitespace prevent the env variable declared on the following line from being loaded.
Additional information
No response
Metadata
Metadata
Assignees
Labels
dotenvIssues and PRs related to .env file parsingIssues and PRs related to .env file parsing