0

I tried installing hombrew for mac os and faced some issues while adding to path, now terminal welcomes me with this messages, how can I fix it?

.zprofile:export:4: not valid in this context: export HOMEBREW_PREFIX
.zshrc:export:1: not valid in this context: Support/JetBrains/Toolbox/scripts

.zprofile :

# Added by Toolbox App
export PATH="$PATH:/Users/randus/Library/Application Support/JetBrains/Toolbox/scripts"eval "$(/opt/homebrew/bin/brew shellenv)"
eval "$(/opt/homebrew/bin/brew shellenv)"

.zshrc :

export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/randus/Library/Application Support/JetBrains/Toolbox/scripts
bobbymurd
  • 11
  • 2
  • Possible duplicate: https://unix.stackexchange.com/q/208607/4667 -- see also https://unix.stackexchange.com/search?q=%5Bzsh%5D+not+valid+in+this+context – glenn jackman Sep 02 '22 at 15:14
  • 1
    Please add the contents of `.zprofile` and `.zshrc` to your question. – Marlon Richert Sep 02 '22 at 16:51
  • This may not be what you want to hear, but FWIW my ***opinion*** - after using both `homebrew` and `MacPorts` for several years - is this: `MacPorts` is a far better choice for a macos package manager than `homebrew`. But don't take my word for it - research this yourself. – Seamus Sep 02 '22 at 16:59
  • 1
    FWIW, Those are the errors you'd get if `~/.zprofile` contained: `export 'export HOMEBREW_PREFIX'` and `~/.zshrc` contained `export Support/JetBrains/Toolbox/scripts` – Stéphane Chazelas Sep 02 '22 at 17:50
  • @glennjackman, newer versions of zsh treat `export` as dual keyword/builtins like ksh does. So `export var=$(cmd)` no longer subjects the command substitution to word splitting. `not valid in this context: export HOMEBREW_PREFIX` is evidence that the space between `export` and `HOMEBREW_PREFIX` didn't trigger splitting. – Stéphane Chazelas Sep 02 '22 at 17:52
  • @StéphaneChazelas I can find SH_WORD_SPLIT on by default in Zsh’s Git log as back as the first commit in 1999. So, I don’t think it’s quite accurate to say “newer versions of zsh”. ;) – Marlon Richert Sep 05 '22 at 05:54
  • @MarlonRichert, not sure what you mean, shwordsplit is about splitting *parameter expansions* and has never been on by default except in sh/ksh emulation. zsh has always done IFS-splitting on *command substitutions* in list context. The change I'm refering to is [this one](https://github.com/zsh-users/zsh/commit/39b28980f38e83e15cdeb19a489b5659af97fe93) which makes it that `export var=$(cmd)` is no longer a list context as `var=$(cmd)` is interpreted as assignment – Stéphane Chazelas Sep 05 '22 at 07:49
  • Ah, sorry, misread your comment. – Marlon Richert Sep 05 '22 at 09:57

1 Answers1

2

Put space between export PATH="$PATH:/Users/randus/Library/Application Support/JetBrains/Toolbox/scripts" and eval "$(/opt/homebrew/bin/brew shellenv)"

Steps:

  • nano /Users/randus/.zprofile
  • Add space after scripts", so finally your zprofile contents should look like export PATH="$PATH:/Users/randus/Library/Application Support/JetBrains/Toolbox/scripts" eval "$(/opt/homebrew/bin/brew shellenv)"
  • Control + O
  • Enter
  • Control + X
  • Restart terminal
Aman
  • 21
  • 1