I have an issue setting an environment variable on my MacBook Pro running macOS High Sierra.
In the terminal, I tried to setup an environment variable by executing
export VARIABLE_URL=example.com. I then tried to check that the environment variable was set with
echo $VARIABLE_URL, but it returned a blank result.
Now whenever I start up the terminal, I get this message:
Last login: Tue Apr 2 15:08:56 on ttys000  Done export VARIABLE_URL=example.com  Done appVersion=  Done osVersion=  Done deviceType= + Done deviceId= My-MacBook-Pro:~ me$
I tried adding the variable to my
.bash_profile file, but even this doesn't set the variable properly. Every time I do
echo $VARIABLE_URL, it returns blank.
I've set other variables in my
.bash_profile, but this is the only variable that my computer refuses to add.
Even when I execute
printenv, all environment variables are displayed except for
Why can't I set this environment variable?
Edit: Here is the contents of my
export BACKEND=example export VARIABLE_URL=example.com export HOST=localhost export BASEURL=example export SECRET=example export USERNAME=example export ACCESS_KEY=example
Edit2: Here is what is displayed when I open the terminal now:
Last login: Wed Apr 3 13:06:20 on ttys000 + export BACKEND=example + BACKEND=example + export 'VARIABLE_URL=example.com' + VARIABLE_URL='example.com' + appVersion= + osVersion= + deviceType= + clientType= + export HOST=localhost + HOST=localhost + export BASEURL=example + BASEURL=example + export SECRET=example + SECRET=example + export USERNAME=example + USERNAME=example + export ACCESS_KEY=example + ACCESS_KEY=example + deviceId= My-MacBook-Pro:~ me$
...and here is what is returned when
printenv is executed:
TERM_PROGRAM=Apple_Terminal USERNAME=example SHELL=/bin/bash TERM=xterm-256color TMPDIR=/var/folders/g6/q9bwlzxn36jfb2j53c5t_t080000gn/T/ Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.GZQ9CxlO7F/Render TERM_PROGRAM_VERSION=404.1 TERM_SESSION_ID=45B1D3A5-719E-4C24-9026-C52A374B3809 USER=me SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.nXK7LMtVZx/Listeners BACKEND=example SECRET=example HOST=localhost PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Wireshark.app/Contents/MacOS PWD=/Users/me LANG=en_US.UTF-8 XPC_FLAGS=0x0 XPC_SERVICE_NAME=0 SHLVL=1 HOME=/Users/me LOGNAME=me ACCESS_KEY=example BASEURL=example _=/usr/bin/printenv My-MacBook-Pro:~ me$
Final Edit: It's been solved! Adding single quotes to the URL did the trick:
I should have explicitly explained that the URL shown in this questions is a placeholder URL, not the one that was actually in my
.bash_profile. The actual URL does in fact contain multiple
& characters. I'm sorry for not explaining that from the start. I feel that if I had done so, the problem would have been solved sooner. Regardless, thanks to everyone for their help and suggestions, I'm very happy to have this all sorted out now.