简体   繁体   English

每次打开终端时 Zsh 都显示失败

[英]Zsh show fail every time when I open my terminal

I'm using a Mac with OS X Yosemite and Zsh.我正在使用装有 OS X Yosemite 和 Zsh 的 Mac。 By accident,I delete the content of three files below: .bashrc .bash_profile .profile After that ,when I open my terminal.偶然地,我删除了以下三个文件的内容: .bashrc .bash_profile .profile 之后,当我打开我的终端时。 The Zsh will show fail under the last login information,it confused me ,and I want to know why. Zsh 会在上次登录信息下显示失败,这让我很困惑,我想知道为什么。

Zsh (by default) doesn't read from .bashrc , .bash_profile , or .profile , so the contents of these files shouldn't matter. Zsh(默认情况下)不从.bashrc.bash_profile.profile读取,因此这些文件的内容应该无关紧要。 You also didn't mention which .bashrc , .bash_profile , and .profile were erased… These files exist in both your /Users/username directory and /etc .您也没有提到哪些.bashrc.bash_profile.profile被删除了……这些文件存在于您的/Users/username目录和/etc The files sourced by zsh at startup are listed in the OS X zsh man page ( man zsh in a terminal) under "STARTUP/SHUTDOWN FILES".启动时由 zsh 获取的文件列在OS X zsh 手册页(终端中的man zsh )中的“STARTUP/SHUTDOWN FILES”下。 The only reason it would call one of the previously mentioned files is if they were explicitly source d in one of the default files.它会调用前面提到的文件之一的唯一原因是它们是否在默认文件之一中显式source d。

My suggestions:我的建议:

  • Check the contents of /etc/zshenv (this is the only zsh-specific file in my etc directory).检查/etc/zshenv的内容(这是我的etc目录中唯一特定于 zsh 的文件)。 Mine has only the following:我的只有以下几点:

     # system-wide environment settings for zsh(1) if [ -x /usr/libexec/path_helper ]; then eval `/usr/libexec/path_helper -s` fi
  • Can you log in at all using zsh?你能用zsh登录吗? If not, can you log in using another shell?如果没有,您可以使用另一个shell登录吗? You can do this in the OS X Terminal.app by going to Preferences -> General and changing the option for "Shells open with:" from "Default login shell" to Command (fill in another shell, ie, /bin/bash or /bin/sh ).您可以在 OS X Terminal.app 中执行此操作,方法是转到 Preferences -> General 并将“Shells open with:”选项从“Default login shell”更改为 Command(填写另一个 shell,/bin/bash/bin/sh )。 If you can log in with any shell, try the following solution from this question :如果您可以使用任何 shell 登录,请尝试此问题中的以下解决方案:

    Looking for the error寻找错误

    All shell output goes to the terminal, so you could just redirect it when starting it.所有 shell 输出都发送到终端,因此您可以在启动它时重定向它。 As you are looking for error messages during initialisation, I'd suggest the following procedure:当您在初始化期间查找错误消息时,我建议执行以下步骤:

    1. Disable the problematic configurations禁用有问题的配置
    2. Open a terminal打开终端
    3. Check the value of SHLVL : echo $SHLVL检查SHLVL的值: echo $SHLVL
    4. Re-enable the configurations重新启用配置
    5. Start a new z-shell from within the running shell with zsh 2> zsh-error.log , this redirects stderr to the file 'zsh-error.log'.使用zsh 2> zsh-error.log从正在运行的 shell 中启动一个新的 z-shell,这会将stderr重定向到文件“zsh-error.log”。
    6. Check the value of SHLVL again.再次检查SHLVL的值。 If it is bigger then previous value then exit the current shell ( exit ).如果它大于先前的值,则退出当前 shell ( exit )。 (Explanation below) (解释如下)
    7. Have a look at 'zsh-error.log' in the current directory.查看当前目录中的“zsh-error.log”。

    If 'zsh-error.log' does not show anything, you may want to run zsh -x 2> zsh-error.log in step 5 instead.如果 'zsh-error.log' 没有显示任何内容,您可能需要在第 5 步中运行zsh -x 2> zsh-error.log This provides a complete debug output of anything zsh does.这提供了 zsh 所做的任何事情的完整调试输出。 This can get quite huge.这可能会变得非常巨大。

    As the answer suggests, those logs can get enormous if you are sourcing man files at startup.正如答案所暗示的那样,如果您在启动时获取 man 文件,这些日志会变得非常庞大。 Just a bare shell should result in a reasonably small log file.只是一个裸壳应该会产生一个相当小的日志文件。

  • Finally, you can retrieve a list of all the files sourced by zsh on startup by running zsh -o sourcetrace .最后,您可以通过运行zsh -o sourcetrace检索启动时由zsh -o sourcetrace获取的所有文件的列表。

Hope this helps.希望这可以帮助。

You might want to look at a duplicate question: Zshell starts up with exit status of 1 after uninstalling RVM您可能想查看一个重复的问题: Zshell 在卸载 RVM 后以 1 的退出状态启动

It has an answer that solved the issue for me:它有一个为我解决问题的答案:

I found a .zlogin file on my system that contained some rvm-related code.我在我的系统上发现了一个 .zlogin 文件,其中包含一些与 rvm 相关的代码。 I've deleted the code, and the problem is solved!我把代码删了,问题解决了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果我的(zsh)Shell每次打开终端时都向我抛出这些错误/警告,那是什么意思? - What does it mean if my (zsh) shell throws these errors/warnings at me every time I open the terminal? 每次打开终端时需要重新加载bash吗? - Need to reload bash every time i open terminal? 如何修改我的 zsh 终端提示符以显示当前工作目录和当前 git 分支(如果适用)? - How can I modify my zsh terminal prompt to show the current working directory and current git branch (if applicable)? 每次打开终端时都会出错,我收到“zsh:找不到命令” - Error everytime I open Terminal I get "zsh: command not found" 运行 mongod 时 zsh 终端输出显示键值 - zsh terminal output show key value when run mongod not a valid identifier Mac OS Terminal 每次打开它时都会返回错误。 与 PATH 变量有关? - not a valid identifier Mac OS Terminal returning an error every time I open it. Related to PATH variable? 每次打开项目时 Xcode 都会意外退出 - Xcode quits unexpectedly every time I open my project 为什么我的 MacOS 终端每次启动时都要求输入密码? - Why does my MacOS terminal ask for my password every time I start it? 无法在 Mac 终端 ZSH 中打开 Postgres shell - Unable to Open Postgres shell in Mac Terminal ZSH 打开 iTerm-zsh 或终端后出错 - Error after open iTerm-zsh or Terminal
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM