zsh 中的 $PATH(我认为) 搞砸了
当我尝试在终端中执行 ls 时,它说找不到命令。
在我破坏一切之前, echo $PATH 的输出是这样的:
/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/gabrijelagavric/.gem/ruby/2.6.5/bin:/用户s/gabrijelagavric/.rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/bin:/Users/gabrijelagavric/.rubies/ruby-2.6.5/bin:
我试图跟随一些线程,但我似乎不明白我具体需要运行什么来更改我的 .zshrc 文件(该线程说要更改 .zshrc 中的 PATH 变量: 在 zsh 上找不到命令)
因此,我将其粘贴到终端中:
echo "export PATH=/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/gabrijelagavric/.gem/ruby/2.6.5/bin:/U sers/gabrijelagavric/.rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/bin:/Users/gabrijelagavric/.rubies/ruby-2.6.5/bin:" >>> ~/.zshrc
然后 source ~/.zshrc"
但后来我得到了这个回复
/Users/gabrijelagavric/.oh-my-zsh/oh-my-zsh.sh:117: command not found: rm
detect-clipboard:33: command not found: uname
/usr/local/opt/chruby/share/chruby/chruby.sh:5: command not found: ls
/Users/gabrijelagavric/.zshrc:export:107: not valid in this context: /Users/gabrijelagavric/.gem/ruby/2.6.5/bin:/Users/gabrijelagavric/.rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/bin:/Users/gabrijelagavric/.rubies/ruby-2.6.5/bin:```
When i try to do ls in the terminal, it says command not found.
Before I broke everything, the output of echo $PATH was something like this:
/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/gabrijelagavric/.gem/ruby/2.6.5/bin:/Users/gabrijelagavric/.rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/bin:/Users/gabrijelagavric/.rubies/ruby-2.6.5/bin:
I was trying to follow along with some threads but I don't seem to understand what specifically I need to run to change my .zshrc file (this thread said to change PATH variable in .zshrc: commands not found on zsh)
So, I pasted this into the terminal:
echo "export PATH=/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/gabrijelagavric/.gem/ruby/2.6.5/bin:/Users/gabrijelagavric/.rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/bin:/Users/gabrijelagavric/.rubies/ruby-2.6.5/bin:" >> ~/.zshrc
And then source ~/.zshrc"
But then i got this response
/Users/gabrijelagavric/.oh-my-zsh/oh-my-zsh.sh:117: command not found: rm
detect-clipboard:33: command not found: uname
/usr/local/opt/chruby/share/chruby/chruby.sh:5: command not found: ls
/Users/gabrijelagavric/.zshrc:export:107: not valid in this context: /Users/gabrijelagavric/.gem/ruby/2.6.5/bin:/Users/gabrijelagavric/.rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/bin:/Users/gabrijelagavric/.rubies/ruby-2.6.5/bin:```
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我修复的方式遵循他们的评论中“用户1934428”提供的答案(尽管他们实际上没有回答,所以我不知道如何指定他们解决了”,
他们的建议是在文本编辑器中编辑文件 。
vs代码
The way I fixed this was following the answer provided by "user1934428" in their comment (though they didn't actually answer it so I don't know how to specify they resolved it"
Their suggestion was to edit the file in a text editor.
Thank you user1934428, your solution helped. Thank you to Mashuptwice and Chapner as well for answering as well.
您已经将新的
$ PATH
变量添加到最后一行(>>
)中,并将其添加到您的.zshrc
文件中。删除文件的最后一行以恢复更改。如果将来要添加
$ path变量,无需完全替换它。
You've added the new
$PATH
variable as last line (>>
) to your.zshrc
file. Remove the last line of the file to revert the changes.If you want to add a path to
$PATH
in the future, you can usePATH=$PATH:/new/path/appended/to/variable
to add something to the variable, without completely replacing it.由于我在调整.zshrc中的内容时打破了路径,因此我无法使用终端命令启用“隐藏文件”。以下是我采取的步骤:
vs代码,Atom,Sublime等)Open
)finder
finder 并导航到您的用户(您可以右键单击在顶部的文件夹名称以获取当前文件夹的下拉列表,并且是父母)⌘⇧。
(命令示单点
)以显示隐藏的文件。Since I broke my path while tweaking things in my .zshrc, I could not enable "show hidden files" with the terminal command. Here are the steps I took:
VS Code, Atom, Sublime, etc
)Finder
and navigate to your user (you can right click the folder name at the top to get a dropdown of your current folder and it's parents)⌘⇧.
(Command-Shift-Dot
) to show hidden files.