zsh 中的 $PATH(我认为) 搞砸了

发布于 2025-01-17 14:26:33 字数 1269 浏览 0 评论 0原文

当我尝试在终端中执行 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

迷你仙 2025-01-24 14:26:33

我修复的方式遵循他们的评论中“用户1934428”提供的答案(尽管他们实际上没有回答,所以我不知道如何指定他们解决了”,

他们的建议是在文本编辑器中编辑文件 。

  1. 文件
  2. 通过CMD+Shift+
  3. 打开
  4. gt

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.

  1. opened vs code
  2. file > open
  3. show hidden files (.zshrc) via cmd+shift+"." (for mac)
  4. made changes
  5. saved

Thank you user1934428, your solution helped. Thank you to Mashuptwice and Chapner as well for answering as well.

奶茶白久 2025-01-24 14:26:33

您已经将新的$ 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 use PATH=$PATH:/new/path/appended/to/variable to add something to the variable, without completely replacing it.

由于我在调整.zshrc中的内容时打破了路径,因此我无法使用终端命令启用“隐藏文件”。以下是我采取的步骤:

  1. 下载您选择的IDE(vs代码,Atom,Sublime等)Open
  2. open finder finder 并导航到您的用户(您可以右键单击在顶部的文件夹名称以获取当前文件夹的下拉列表,并且是父母)
  3. ⌘⇧。命令示单点)以显示隐藏的文件。
  4. 右键单击您的.ZSHRC文件,然后选择“打开”
  5. 选择您的IDE/编辑器
  6. 进行更改并保存

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:

  1. Download an IDE of your choosing (VS Code, Atom, Sublime, etc)
  2. Open 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)
  3. Press⌘⇧.(Command-Shift-Dot) to show hidden files.
  4. Right click your .zshrc file and select "Open With"
  5. Choose your IDE/editor
  6. Make your changes and save
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文