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

Bun trims environment variables #3689

Closed
trnxdev opened this issue Jul 19, 2023 · 7 comments
Closed

Bun trims environment variables #3689

trnxdev opened this issue Jul 19, 2023 · 7 comments
Labels
bug Something isn't working good first issue Something that would be good for new contributors

Comments

@trnxdev
Copy link
Contributor

trnxdev commented Jul 19, 2023

What version of Bun is running?

0.6.15

What platform is your computer?

Linux 6.3.9-zen1-1-zen x86_64

What steps can reproduce the bug?

a.js:
console.log(process.env.EXAMPLE, process.env.EXAMPLE == " hi")

console:
EXAMPLE=" hi" bun run a.js

What is the expected behavior?

" hi true" in the terminal. (like node.js)

What do you see instead?

"hi false" in the terminal

Additional information

I found this bug while working on #3661,
also it works correctly if the env is set in .env

image

@trnxdev trnxdev added the bug Something isn't working label Jul 19, 2023
@trnxdev
Copy link
Contributor Author

trnxdev commented Jul 19, 2023

image
may this be the line which breaks it? (src/env_loader.zig, line 690)

UPD: probably not, removing this does not seem to fix the issue. But I might be wrong

@dylan-conway dylan-conway added the good first issue Something that would be good for new contributors label Jul 19, 2023
@clemg
Copy link

clemg commented Jul 23, 2023

On my side it seems to be fine when using the dev/release builds (no space trimmed)
When using the public bun bin its different, tf?

is the publicly shared bin different from the release build?

@clemg
Copy link

clemg commented Jul 23, 2023

image may this be the line which breaks it? (src/env_loader.zig, line 690)

UPD: probably not, removing this does not seem to fix the issue. But I might be wrong

I think it's because when parsing the value, the spaces get ignored at the beginning because of env_loader.zig#L695C1-L695C1

@iMrDJAi
Copy link

iMrDJAi commented Jul 23, 2023

Related #3743 (comment)

@trnxdev
Copy link
Contributor Author

trnxdev commented Jul 23, 2023

Related #3743 (comment)

I think what you're looking for is #3716

@clemg
Copy link

clemg commented Jul 23, 2023

then we might want to mark this as closed

@trnxdev
Copy link
Contributor Author

trnxdev commented Jul 23, 2023

oh yeah, seems to be fixed
image

@trnxdev trnxdev closed this as completed Jul 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Something that would be good for new contributors
Projects
None yet
Development

No branches or pull requests

4 participants