0

I have a variable set exactly like this:

export VARIABLE_NAME=VARIABLE_VALUE

I thought it would be in ~/.zshrc or bash_profile but it is seen in none of those. I am now struggling to understand where its getting set and I want to reset it up. Can someone suggest easy way to do so? I am on MacOS

I am using zsh shell. I know the command called unset VARIABLE_NAME. However I am looking into finding root cause and removing the variable from the first place where its been set.

Variable name is JWT_SECRET

Update:

I tried running grep JWT_SECRET {~/.z,/etc/z}{shenv,profile,shrc,login} as proposed by @nohillside

I have configured my zsh to use ohmyzsh.

Here's how output looks like:

enter image description here

When I do: echo $SHELL $ZSH_VERSION $BASH_VERSION I get: /bin/zsh 5.9

Here's what I have in my ~/.zshrc:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
DISABLE_AUTO_TITLE="true"
PS1="%1d %& # "
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="robbyrussell"
ENABLE_CORRECTION="true"
plugins=(git)
source $ZSH/oh-my-zsh.sh
export SU_PASSWORD=<PASSWORD>
export SU_USERNAME=<USERNAME>
export PATH="/Users/<username>/bin:$PATH"
4
  • No problem with that output. You do have ~/.zshrc obviously, so as a next step, look into that one to see where it calls additional commands which could set env variables.
    – nohillside
    Jun 11 at 10:56
  • I have added more details about my zsh shell content. Can you please check that once and see if you find something? Jun 11 at 11:04
  • As I said: You need to look into the commands run from there. . "$NVM_DIR/nvm.sh" seems to be a good candidate for this.
    – nohillside
    Jun 11 at 11:06
  • It seems like it was cached somewhere. I tried source multiple times but it appeared everytime. I restarted my system and now variable seems to have disappeared. Thanks a lot @nohillside for helping me out here!!! Jun 11 at 11:17

1 Answer 1

2

This variable can be set in any of the files zsh reads at startup, or in any command called from one of these files. According to the man page, these are (with ZDOTDIR defaulting to HOME)

$ZDOTDIR/.zshenv
$ZDOTDIR/.zprofile
$ZDOTDIR/.zshrc
$ZDOTDIR/.zlogin
/etc/zshenv
/etc/zprofile
/etc/zshrc
/etc/zlogin

So as a first attempt, run

grep JWT_SECRET {~/.z,/etc/z}{shenv,profile,shrc,login}

Ignore any "file not found" errors, and check whether it returns a match. If it doesn't, you need to manually look at each of these files (if they exist) and check for any commands which could actually set the variable.

3
  • All of those returned no such file or directory. Hmm Jun 11 at 10:19
  • All? Or just some, which should have the name mentioned in the message? What does echo $SHELL $ZSH_VERSION $BASH_VERSION say?
    – nohillside
    Jun 11 at 10:23
  • Yep al, I have updated the question with the same too Jun 11 at 10:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .