kube-ps1 icon indicating copy to clipboard operation
kube-ps1 copied to clipboard

_kube_ps1_file_newer_than:16: division by zero

Open nareshku opened this issue 3 years ago • 4 comments

Using kube-ps1 on my Linux machine with zsh and found that zstat doesn't output nanoseconds leading to error _kube_ps1_file_newer_than:16: division by zero

zstat +mtime -F %s.%N ~/kube/config
1658797744.%N

Full output of zstat

zstat ~/.kube/config
device  64768
inode   68653976
mode    33152
nlink   1
uid     37543
gid     101
rdev    0
size    18637
atime   1658797746
mtime   1658797744
ctime   1658797744
blksize 4096
blocks  40
link

We should probably get the OS type and convert command zstat +mtime -F %s.%N to zstat +mtime -F %s if it is Linux here

nareshku avatar Jul 26 '22 21:07 nareshku

Interesting. Which version of zsh are you using? I am running Linux and tested on different distributions without that issue:

$ zsh --version
zsh 5.8 (x86_64-ubuntu-linux-gnu)                                             
testuser at dev-box in ~ 

$ zstat +mtime -F %s.%N ~/.kube/config          
1658946238.553962684                                           
testuser at dev-box in ~ 
$ 

jonmosco avatar Jul 27 '22 19:07 jonmosco

zsh --version
zsh 5.0.2 (x86_64-redhat-linux-gnu)

nareshku avatar Jul 27 '22 19:07 nareshku

Wow, ok. This version was released almost 10 years ago: 2012-12-21. I assume you are on an older version of RHEL? The nanosecond precision was introduced around version 5.5. I will add a condition for older versions of ZSH but would definitely suggest upgrading your shell at some point.

jonmosco avatar Jul 27 '22 20:07 jonmosco

I also got this issue:

_kube_ps1_file_newer_than:15: division by zero
zsh --version
zsh 5.0.2 (x86_64-redhat-linux-gnu)

astraw99 avatar Aug 16 '22 03:08 astraw99