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

Unexpected output when using 'PROMPT' environment variable with dotenv #850

Closed
VArtzy opened this issue Dec 27, 2024 · 2 comments
Closed

Comments

@VArtzy
Copy link

VArtzy commented Dec 27, 2024

When using dotenv to load an environment variable named PROMPT, I noticed unexpected behavior.

Steps to Reproduce:

  1. Create a .env file with the following content:
    PROMPT=test
    
  2. Use the following index.js file:
    import 'dotenv/config';
    console.log(process.env.PROMPT);
  3. Run the script:
    $ node index.js
    

Expected Behavior:

The output should be:

test

Observed Behavior:

The output was:

$P$G
@motdotla
Copy link
Owner

I cannot repeat this and I would be hugely surprised if this was failing for 10 years and no one discovered it.

More than likely, you already have PROMPT set on your env. Try running:

env

on your machine to check.

If you don't see it there then if you are using a framework then it is likely doing its own loading of environment variables and I would raise the issue with them please. Thank you.

Also, you might find dotenvx makes this easier to debug in the future.

@VArtzy
Copy link
Author

VArtzy commented Dec 27, 2024

Okay thanks, I wasn’t aware that another software had set the system env variable

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