agkozak/zsh-z

_zshz_update_datafile:37: division by zero

Closed this issue · 7 comments

I installed zsh-z using oh-my-zsh and after each command the following line appeared:

_zshz_update_datafile:37: division by zero

I tried using zinit and it kept appearing.

When I removed zsh-z from my .zshrc, this repeating line stopped appearing.

My .zshrc:

### Added by Zinit's installer
if [[ ! -f $HOME/.zinit/bin/zinit.zsh ]]; then
    print -P "%F{33}▓▒░ %F{220}Installing %F{33}DHARMA%F{220} Initiative Plugin Manager (%F{33}zdharma/zinit%F{220})…%f"
    command mkdir -p "$HOME/.zinit" && command chmod g-rwX "$HOME/.zinit"
    command git clone https://github.com/zdharma/zinit "$HOME/.zinit/bin" && \
        print -P "%F{33}▓▒░ %F{34}Installation successful.%f%b" || \
        print -P "%F{160}▓▒░ The clone has failed.%f%b"
fi

source "$HOME/.zinit/bin/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit

# Load a few important annexes, without Turbo
# (this is currently required for annexes)
zinit light-mode for \
    zinit-zsh/z-a-as-monitor \
    zinit-zsh/z-a-patch-dl \
    zinit-zsh/z-a-bin-gem-node

### End of Zinit's installer chunk

# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH

# Path to your oh-my-zsh installation.
export ZSH="/Users/angelodias/.oh-my-zsh"

# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
# ZSH_THEME="robbyrussell"
ZSH_THEME="powerlevel10k/powerlevel10k"

DEFAULT_USER="angelo"

plugins=( git node osx http npm zsh-z )

source $ZSH/oh-my-zsh.sh

export PATH=/usr/local/bin:$PATH

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

# KEY BINDING
bindkey -e
bindkey '^[[1;9C' forward-word
bindkey '^[[1;9D' backward-word
prompt_context () { }

NPM_PACKAGES=/Users/angelodias/.npm-packages

export NVM_DIR="/Users/angelodias/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm

# ALIASES
alias srcz="source ~/.zshrc"
alias config="code ~/.zshrc"
alias g="cd ~/git"
alias boot="cd ~/git/bootcamp/"
alias mongo-terminate="pkill mongod"
alias dev="yarn develop"

zinit light zsh-users/zsh-autosuggestions
zinit light zsh-users/zsh-completions
zinit light zdharma/fast-syntax-highlighting

# colorLS
source $(dirname $(gem which colorls))/tab_complete.sh
alias lc='colorls -lA --sd'
alias ls='colorls --almost-all --report --git-status --sort-dirs'

export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
export PATH="$PATH:$(yarn global bin)"
export PATH="$HOME/.config/yarn/global/node_modules/.bin:$PATH"
export ANDROID_HOME=~/android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools

OK. Thanks for supplying your .zshrc -- that makes my job easier!

I added zinit light agkozak/zsh-z, installed colorls and yarn, and commented out source $ZSH/oh-my-zsh.sh. No problems.

I use a fresh copy of your .zshrc, commented out all the zinit code, changed all instances of /Users/angelodias/ to $HOME/, installed powerlevel10k, and agkozak/zsh-z.

What's the http plugin? Where is its repository located? I'd like to try that out.

Anyway, so far I haven't run into your problem. I suspect that something you're using is interfering with zsh-z, and I'd love to know what it is so that I can make sure it never happens. I'll probably need a little more information.

Start out by telling me what the http plugin is. Thanks!

Also, type

 z -l

and tell me what it shows you. Thanks.

If I comment source $ZSH/oh-my-zsh.sh, my powerlevel10k configs aren't loaded.

I'm gonna confess I have no idea what the HTTP plugin does. I might have installed it in the past because reasons. I removed it from my plugins section but the error kept happening.

Another information: I'm on Mac using iTerm2.

Log from z -l:

_zshz_find_matches:43: division by zero
0.25       /Applications/iTerm.app
0.25       /Users/angelodias/Library/Application Support/Steam/SteamApps
0.25       /Users/angelodias/Music
0.25       /Users/angelodias/Music/Ableton
0.50       /Users/angelodias/Library/Application Support/iCloud/Accounts
0.50       /Users/angelodias/android/sdk/tools
0.51       /Users/angelodias/Library/Application Support/Steam/SteamApps/common/RimWorld
0.75       /Users/angelodias/Library/Audio
0.75       /Users/angelodias/Music/Ableton/User Library
0.76       /Users/angelodias/GIT/comida/src/assets/scripts/components/map
0.76       /Users/angelodias/GIT/cronofobia/docs
1          /Users/angelodias/.config
1          /Users/angelodias/Library/Preferences/org.videolan.vlc
1.01       /Users/angelodias/GIT/umbler
1.01       /Volumes
1.02       /Users/angelodias/Library/Application Support/Steam/SteamApps/common
1.02       /Users/angelodias/android
1.25       /Users/angelodias/Applications
1.27       /Users/angelodias/Library/Application Support/RimWorld
1.32       /usr/local/apache2/conf
1.43       /Users/angelodias/GIT/bootcamp/docker
1.50       /Users/angelodias/Documents
1.53       /Users/angelodias/android/sdk
2          /usr/local/include
2.38       /Users/angelodias/Library/Developer/Xcode/DerivedData
2.53       /Users/angelodias/GIT/TF/tf
2.65       /Users/angelodias/GIT/utils
2.76       /Users/angelodias/GIT/mae-urso/public
2.77       /Users
3.01       /Users/angelodias/Downloads
3.50       /usr/local/bin
4.03       /usr/local/lib
4.28       /Users/angelodias/Library
4.54       /Users/angelodias/Desktop
5.26       /Users/angelodias/GIT/bootcamp/04-iniciando-back-end
5.58       /Users/angelodias/GIT/escolha-escola-folha
5.59       /Users/angelodias/GIT/class-scraper
6.57       /Users/angelodias/GIT/boilerplate-folha
7.27       /Users/angelodias/.ssh
28.29      /Users/angelodias/GIT/bootcamp/gobarber_mobile
64.48      /Users/angelodias/GIT/bootcamp/06-gobarber-web
244.77     /Users/angelodias/GIT/bootcamp
334.22     /Users/angelodias/GIT/portfolio
764.52     /Users/angelodias/GIT
_zshz_update_datafile:37: division by zero

(see the error on different lines? 37 and 43)

(is there a way to clean this cache?)

EDIT: formatting

If I comment source $ZSH/oh-my-zsh.sh, my powerlevel10k configs aren't loaded.

That makes sense. I was commenting it out because I didn't want to have oh-my-zsh and zinit running at the same time.

Yes, you can remove the whole cache simply by running

rm ~/.z

In fact, why don't you try that and then cd around a bit just to see if there's something corrupt in the cache? Let me know if that makes a positive difference. Meanwhile, I'll think about this problem a bit.

Just so I know, which version of ZSH are you running? You can check by typing

echo $ZSH_VERSION

Thanks again for your patience.

Oh, and could you tell me what happens when you type

echo $EPOCHSECONDS

and could you type

zmodload

and make sure zsh/datetime is in the list? Thanks.

Cleaning the cache did it. I don't know if it's described in the docs, but I'd recommend a section about it.

I think I got it! Counting my z -l lines, line 37 and 43 are folders that doesn't exist anymore. Maybe this is messing up stuff, as your program searches for an unexisting path.

Anyways, just FYI, zhs version 7.7.1, epoch seconds returned me 1593205422 (which I assume is timestamp) and zsh/datetime is indeed part of zmodload list.

Problem solved, won't close the issue if you need to ask something else. If not, close away :) And thank you very much, this has been a HUGE time saver (so there's no need to thank me for my patience 👍 )

Thanks. And I'm glad it works for you now.