3

I did something for installing a particular version of java and adding it to the path by looking at and reading various articles. But for a few days now, whenever I open my Mac terminal, this is what I get, this text. How can I remove it?

This is what I see on my Mac terminal.

Please click here for the terminal picture

HOME=/Users/abhishekshah
LANG=en_US.UTF-8
LOGNAME=abhishekshah
OLDPWD=/Users/abhishekshah
PATH=/usr/bin:/bin
PWD=/Users/abhishekshah
SHELL=/bin/zsh
SHLVL=1
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.SwNOWQsVIR/Listeners
TERM=xterm-256color
TERM_PROGRAM=Apple_Terminal
TERM_PROGRAM_VERSION=444
TERM_SESSION_ID=D558C190-743E-4CA7-9E11-6F4D7403B0BD
TMPDIR=/var/folders/5z/8hmt3tz15n1fchdd_c497qh00000gn/T/
USER=abhishekshah
XPC_FLAGS=0x0
XPC_SERVICE_NAME=0
__CFBundleIdentifier=com.apple.Terminal
HOME=/Users/abhishekshah
LANG=en_US.UTF-8
LOGNAME=abhishekshah
OLDPWD=/Users/abhishekshah
PATH=/usr/bin:/bin
PWD=/Users/abhishekshah
SHELL=/bin/zsh
SHLVL=1
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.SwNOWQsVIR/Listeners
TERM=xterm-256color
TERM_PROGRAM=Apple_Terminal
TERM_PROGRAM_VERSION=444
TERM_SESSION_ID=D558C190-743E-4CA7-9E11-6F4D7403B0BD
TMPDIR=/var/folders/5z/8hmt3tz15n1fchdd_c497qh00000gn/T/
USER=abhishekshah
XPC_FLAGS=0x0
XPC_SERVICE_NAME=0
__CFBundleIdentifier=com.apple.Terminal
abhishekshah@Abhisheks-MacBook-Pro-2 ~ %
  • Obviously one of your zsh startupfiles is dumping a sorted list of your environment. Start your shell with `-x` turned on to see where this happens. – user1934428 Apr 27 '22 at 08:01
  • What exactly do you mean by -x turned on? I am new to Mac. Can you please help? – Abhishek Shah Jun 07 '22 at 04:35
  • This is not related to the Mac, but to `zsh` in general. If you pass the `-x` option to zsh, or alternatively do a `set -x`, it traces the execution. In your case I would simply start a new login-subshell with `zsh -l -x` and then analyze the output. It is often easier than manually inspecting all the startup files, as Rob Mayoff is suggesting, because it's too easy to overlook something. – user1934428 Jun 07 '22 at 06:32

6 Answers6

3

Open your ~/.zshrc or some other zsh startup file and make sure you have no explicit line break on the variables you are exporting. In other words, the variables you are exporting have to be inline.

tcscorp
  • 31
  • 2
1

Faced this issue after I edited .zshrc file to add path. I had added this line:

export PATH = "$PATH:YOUR_PATH"

and then ran command source .zshrc which gave this error .zshrc:2: bad assignment and this error was stuck in shell even after restart since .zshrc is a startup file(runs on shell start).

On searching a lot I found the issue here

The assignments in Bash commands and scripts must not have white space characters around the = operator.

after removing white spaces around = operator the issue was resolved.

Note: Also check that statements should not contain newline characters.

Shubham
  • 113
  • 1
  • 7
1

Had the exact same problem and just solved it. In the terminal run zsh -x and scroll down to see exactly what file is causing the unnecessary export to the terminal. For me, this was in my output:

+add-zsh-hook:92> autoload -- shell_session_update
+/Users/chie/.zshrc:1> export
DISPLAY=/private/tmp/com.apple.launchd.ADcsvecDjX/org.xquartz:0
HOME=/Users/chie
LANG=ja_JP.UTF-8
...

...which meant that the issue was in the file ~/.zshrc which I had mistakenly edited (I had accidentally put a line break between export and PATH)

chiekemi
  • 21
  • 4
0

Probably the installer added an env or printenv command to your ~/.zshrc or some other zsh startup file. Check section “STARTUP/SHUTDOWN FILES” in the zsh man page for the complete list of files you might need to inspect.

rob mayoff
  • 375,296
  • 67
  • 796
  • 848
0

Remove break between export and path This worked for me

Afnan
  • 5
  • 3
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/34771704) – soundflix Aug 03 '23 at 14:35
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 07 '23 at 05:14
-1

Open Terminal and enter

rm .zshenv

It will fix your issue but it may cause other issues. Copy the contents of your .zshenv file before executing the remove command

Jon
  • 9