[英]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。
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:
当您在初始化期间查找错误消息时,我建议执行以下步骤:
- Disable the problematic configurations
禁用有问题的配置
- Open a terminal
打开终端
- Check the value of
SHLVL
:echo $SHLVL
检查
SHLVL
的值:echo $SHLVL
- Re-enable the configurations
重新启用配置
- 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”。- Check the value of
SHLVL
again.再次检查
SHLVL
的值。 If it is bigger then previous value then exit the current shell (exit
).如果它大于先前的值,则退出当前 shell (
exit
)。 (Explanation below)(解释如下)
- 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.