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

dotenv.config() truncates leasing '=' #140

Closed
liorshalev01 opened this issue May 2, 2016 · 7 comments
Closed

dotenv.config() truncates leasing '=' #140

liorshalev01 opened this issue May 2, 2016 · 7 comments
Assignees

Comments

@liorshalev01
Copy link

For example:
PASSWORD="=211cb1cdb045df37I"
The leading '=' is required for the correct password input.

@jcblw
Copy link
Collaborator

jcblw commented May 2, 2016

interesting, have not seen this before. I was able to reproduce with dotenv 2.0.0 and node 6.0.0

# dotenv test .env
PASSWORD="=211cb1cdb045df37I"

and the command

node -r dotenv/config -e "console.log(process.env.PASSWORD)"

@jcblw jcblw added the bug label May 2, 2016
@jcblw jcblw self-assigned this May 2, 2016
@jcblw jcblw mentioned this issue May 7, 2016
@jcblw
Copy link
Collaborator

jcblw commented May 7, 2016

I wrote some test in #141 I was only able to replicate the bug when using the -r preloading option. @liorshalev01 are you using the preload or at the top of a file?

@jcblw
Copy link
Collaborator

jcblw commented May 7, 2016

After some more testing I noticed that

TEST='=FOO' node -e 'console.log(process.env.TEST)'

will output FOO as well. So it looks like there is some processing that is happing via node that is removing the leading =. I would strongly recommend not relying on this to work in the time being so you do not run into issues going from dev to production and trying to set those just in the machine's environment. If you know this equal sign will always prefix the key I would add it to the key post the env being loaded.

@jcblw
Copy link
Collaborator

jcblw commented May 7, 2016

filed this ticket for this issue nodejs/node#6627

@jcblw
Copy link
Collaborator

jcblw commented May 7, 2016

ok so the feedback nodejs/node#6627 is that this is a side-effect from the shell your using @liorshalev01. I was only able to replicate the bug while using ZSH. Can you confirm that the leading = is retained while using bash.

eg.

bash -l
node start # or how ever you start your app

@liorshalev01
Copy link
Author

Hi,
I had some tests and I can confirm that it might be the shell side effect.
I was able to reproduce it only OSX.
On Ubuntu/Linux it works (e.g., no leading '=').

Thanks,
Lior

@jcblw
Copy link
Collaborator

jcblw commented May 7, 2016

Awesome we are not going to be able to do much about this in the dotenv thanks for the feedback.

@jcblw jcblw closed this as completed May 7, 2016
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

2 participants