.zshrc:export:17: 不适用于此上下文

huangapple go评论56阅读模式
英文:

.zshrc:export:17: not valid in this context

问题

I'm currently struggling with an error in terminal in Mac. Can someone help me to fix it?

I already tried some other forum solutions (using export and other similar solutions), but none of them was useful. <br>

Here's the error <br>

/Users/alessandromasala/.zshrc:export:17: not valid in this context: Preview.app/Contents/Public:/Library/TeX/texbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin

This is the content of my .zshrc

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/alessandromasala/miniconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/Users/alessandromasala/miniconda3/etc/profile.d/conda.sh" ]; then
        . "/Users/alessandromasala/miniconda3/etc/profile.d/conda.sh"
    else
        export PATH="/Users/alessandromasala/miniconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

export PATH=/opt/homebrew/bin:/Users/alessandromasala/miniconda3/bin:/Users/alessandromasala/miniconda3/condabin:/Users/alessandromasala/.pyenv/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion Tech Preview.app/Contents/Public:/Library/TeX/texbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin
英文:

I'm currently struggling with an error in terminal in Mac. Can someone help me to fix it?

I already tried some other forum solutions (using export and other similar solutions), but none of them was useful. <br>
Here's the error <br>
/Users/alessandromasala/.zshrc:export:17: not valid in this context: Preview.app/Contents/Public:/Library/TeX/texbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin

This is the content of my .zshrc

# &gt;&gt;&gt; conda initialize &gt;&gt;&gt;
# !! Contents within this block are managed by &#39;conda init&#39; !!
__conda_setup=&quot;$(&#39;/Users/alessandromasala/miniconda3/bin/conda&#39; &#39;shell.zsh&#39; &#39;hook&#39; 2&gt; /dev/null)&quot;
if [ $? -eq 0 ]; then
    eval &quot;$__conda_setup&quot;
else
    if [ -f &quot;/Users/alessandromasala/miniconda3/etc/profile.d/conda.sh&quot; ]; then
        . &quot;/Users/alessandromasala/miniconda3/etc/profile.d/conda.sh&quot;
    else
        export PATH=&quot;/Users/alessandromasala/miniconda3/bin:$PATH&quot;
    fi
fi
unset __conda_setup
# &lt;&lt;&lt; conda initialize &lt;&lt;&lt;

export PATH=/opt/homebrew/bin:/Users/alessandromasala/miniconda3/bin:/Users/alessandromasala/miniconda3/condabin:/Users/alessandromasala/.pyenv/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion Tech Preview.app/Contents/Public:/Library/TeX/texbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin

答案1

得分: 0

问题在于第17行(export PATH=/opt/homebrew/bin:... 命令),需要引号或转义 VMware Fusion Tech Preview.app 中的空格。实际上,看起来这个命令被过早地展开了,因为它正在替换整个 PATH 值,而不是像通常那样仅添加到它(这意味着它正在替换之前 conda 设置部分所做的任何更改)。

我怀疑整行应该被替换为:

export PATH="/opt/homebrew/bin:$PATH"
英文:

The problem is that on line 17 (the export PATH=/opt/homebrew/bin:... command), the spaces in VMware Fusion Tech Preview.app need to be quoted or escaped. Actually, it looks to me like that command got prematurely expanded, since it's replacing the entire PATH value rather than just adding to it like normal (which means that, for example, it's replacing whatever changes the earlier conda setup part did).

I suspect that entire line should be replaced by:

export PATH=&quot;/opt/homebrew/bin:$PATH&quot;

huangapple
  • 本文由 发表于 2023年5月18日 00:17:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76274193.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定