WHAT I WANT TO DO
$ echo $USERNAME
myusername
$ export USERNAME=newvalue
$ echo $USERNAME
newvalue
WHAT IS HAPPENING
$ echo $USERNAME
myusername
$ export USERNAME=newvalue
$ echo $USERNAME
myusername
WHAT I TRIED
- I tried to use:
sudo
...; - I tried to use:
unset USERNAME
.
USEFUL NOTES
OS: macOS Mojave 10.14
Direnv: https://github.com/direnv/direnv
I am using
zsh
WHAT I DID BEFORE THE ISSUE
I was able to change my environment variable several times using direnv
(https://github.com/direnv/direnv), and everything was working well.
I was able to set local env variables in .envrc
.
Then, I encountered this issue...
SOLUTION
https://unix.stackexchange.com/questions/483469/cannot-change-the-environment-variable
In zsh the
USERNAME
var is magical. It is not a normal exported env var. From the man page:In other shells, like bash and fish, this is not a special var and you can set it just like any other env var: