ohmyzsh / ohmyzsh

🙃 A delightful community-driven (with 2,400+ contributors) framework for managing your zsh configuration. Includes 300+ optional plugins (rails, git, macOS, hub, docker, homebrew, node, php, python, etc), 140+ themes to spice up your morning, and an auto-update tool that makes it easy to keep up with the latest updates from the community.
https://ohmyz.sh
MIT License
173.53k stars 25.89k forks source link

Why my Oh My Zsh startup is slow. It take mostly 4-5s #8536

Closed eneltipi closed 4 years ago

ikesau commented 4 years ago

Yeah, something weird's going on. I updated from 78b07e92 to 4e45e12d and things appear broken. Slow startup, .zshrc scripts are broken.

mcornella commented 4 years ago

Can you post your zshrc files? Can you consistenly reproduce the issue by doing a checkout of the previous commit (should be fast) and the last commit (should be slow)?

ikesau commented 4 years ago
export ZSH="/Users/ike/.oh-my-zsh"

ZSH_THEME="typewritten"

ENABLE_CORRECTION="true"

plugins=(git)

source $ZSH/oh-my-zsh.sh

eval "$(pyenv init -)"

I can reproduce by repeatedly running source ~/.zshrc. It appears to take longer to succeed each time, until eventually the shell outputs pyenv:11: argument list too long: pyenv and becomes non-responsive. This may be a separate issue than the one OP was talking about, though. 🤷‍♂

EDIT: removing the pyenv line doesn't resolve this issue.

mcornella commented 4 years ago

I can reproduce by repeatedly running source ~/.zshrc. It appears to take longer to succeed each time, until eventually the shell outputs pyenv:11: argument list too long: pyenv and becomes non-responsive.

You're running pyenv init again and again, that is why you eventually get an error. The proper way to restart the shell is exec zsh, or restarting the terminal, not using source ~/.zshrc.

ikesau commented 4 years ago

Ah, okay good to know.

However, I've removed the pyenv line, and have tried repeatedly running exec zsh. I get the same behaviour (after the fourth attempt it hangs)

Now this isn't really a problem, as I don't normally run exec zsh repeatedly, but maybe whatever's causing this was the culprit behind my slowdown as it happened in a shell that had been running for a month.

mcornella commented 4 years ago

Look if pyenv is creating a new process instead of using an already running one. I'm not familiar with it but that could be a probable cause.

hgedia commented 4 years ago

Noticing the same issue, is there a way to downgrade to earlier commits to validate ?

nvm , it was nvm.

mcornella commented 4 years ago

You can git checkout older commits to test. You can speed up the process of testing the performance with the command time zsh -ic exit &>/dev/null.

kareemkasem commented 3 years ago

same here and I'm not running pyenv

export ZSH="/home/kareem/.oh-my-zsh"

ZSH_THEME="dracula/dracula"

plugins=(git sudo autojump zsh-syntax-highlighting zsh-autosuggestions)

source $ZSH/oh-my-zsh.sh

function fgit(){
git add .
git commit -m "$1"
git push
}

function kill-port(){
lsof -i :"$1" -t | xargs kill
}

function papirus-color(){   
    echo "what color do you want ?"
    read color  
    papirus-folders -C "$color" --theme Papirus
    papirus-folders -C "$color" --theme Papirus-Dark    
    papirus-folders -C "$color" --theme Papirus-Light
}

alias open="xdg-open"
alias code="code-oss"
alias sudo="sudo "
alias sol="eopkg"
alias re="gnome-terminal || tilix; exit"
alias x="exit"
alias c="clear"
alias figma="figma-linux"
alias cra="create-react-app"
alias post="sudo -u postgres psql"
alias monet="sudo iftop -i wlp2s0"
mcornella commented 3 years ago

Remove plugins one by one and measure the effect that has on zsh startup time with the command above (time zsh -ic exit &>/dev/null), until you find the one that has the biggest impact. You can also run zsh -xv and see if the zsh process hangs on a particular command, or on the contrary, it just runs through the whole thing without stopping at any point.

risingtiger commented 3 years ago

~Noticing the same issue, is there a way to downgrade to earlier commits to validate ?~

nvm , it was nvm.

mcornella, How do you know it was nvm? Seems might be my problem as well, since my terminal has been slow to start since installing nvm. Any ideas of how to to address it?

hgedia commented 3 years ago

@risingtiger , this really was self inflicted. I was calling source /usr/share/nvm/init-nvm.sh

Inside the zshrc , which was slowing it down. Your issue might be different

iNoSec2 commented 3 years ago

git plugins slow mine, since i removed it, it start so much faster

andresdotsh commented 3 years ago

This worked for me. With macOS Big Sur 11.3, Xcode 12.5, Command Line Tools, and iTerm2 fresh installation.

1. Uninstall oh-my-zsh

Instructions here.

2. Install homebrew

Instructions here.

3. Install git (but with homebrew)

brew install git

4. Install oh-my-zsh again

Instructions here.

That's all!

In my case, the thing was that when I installed the Command Line Tools, a git version was installed. And apparently there is an issue between that git version and oh-my-zsh. That was causing a slow startup with the xcodebuild title in the iTerm2 window.

liushuaikobe commented 3 years ago

This worked for me. With macOS Big Sur 11.3, Xcode 12.5, Command Line Tools, and iTerm2 fresh installation.

1. Uninstall oh-my-zsh

Instructions here.

2. Install homebrew

Instructions here.

3. Install git (but with homebrew)

brew install git

4. Install oh-my-zsh again

Instructions here.

That's all!

In my case, the thing was that when I installed the Command Line Tools, a git version was installed. And apparently there is an issue between that git version and oh-my-zsh. That was causing a slow startup with the xcodebuild title in the iTerm2 window.

May I know how to prove it's the cause?