Skip to content
← Back to Community
"Secrets" (System environment variables) not working.
Profile icon
KennyJacobson1

I'm using replit's "Secrets" functionality to add an env variable.

image

But when I try to reference it in my React project, it comes up as undefined.

I try to see if it's even there using a simple printenv, but it's not there.

image

I tried to restart the machine using busybox reboot and check it. Still nothing.

What am I doing wrong?

Voters
Profile icon
Antony-SS
Profile icon
ceilingrat
Profile icon
zkindest
Profile icon
joshkmartinez
Profile icon
KaotycOne88
Profile icon
KennyJacobson1
Comments
hotnewtop
Profile icon
Coder100

did you try doing this in the shell?

cuz ur doing it wrong, it only shows up in the repl env. The shell just runs commands, it actually can't interact with the repl

image

the only way to access it is in the code
🙄🙄🙄🙄🙄🙄🙄

Profile icon
KennyJacobson1

@Coder100 I did try to "access it in the code" using the exact manner repl.it says to. That was the first thing I tried. It didn't work so that's why I tried to see if it I could see it in the shell.

Here it is in the code.
image

Here is the result:
image

Profile icon
Xenity

Did you click save? if you did then it is probably a bug and you should report it. if you did not, then do it again but click save

Profile icon
KennyJacobson1

@Xenity Yep, I clicked save.

Profile icon
Xenity

@KennyJacobson1 then it is probably a replit bug

Profile icon
KennyJacobson1

@Xenity I just reported it.

Profile icon
zkindest

@KennyJacobson1 I am facing the same,issue resolved?

Profile icon
ceilingrat

@zkindest @KennyJacobson1
Same here. Is there a link to the issue?
I'd like to track it and help make sure it gets some attention.

Profile icon
zkindest

@ceilingrat I am able to use node env variables if i use the run button provided by the replit.
Here's my ticket: https://replit.com/talk/ask/secret-variables-are-not-working/140159

Profile icon
ceilingrat

@zkindest
I'm seeing that too. For a Bash repl, it's especially tricky but I have some ideas about how to get the results I want.
If I have some success, I'll share a functioning repl for anyone who's interested.
Thanks for sharing your ticket!