英文:
.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
# >>> 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
答案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="/opt/homebrew/bin:$PATH"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论