Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated install, segments error #100

Open
pulberg opened this issue Sep 28, 2020 · 15 comments
Open

Updated install, segments error #100

pulberg opened this issue Sep 28, 2020 · 15 comments
Labels

Comments

@pulberg
Copy link

pulberg commented Sep 28, 2020

Describe the bug
Updated to latest via homebrew, run sbp reload and get -

/usr/local/opt/sbp/src/main.bash: line 30: COLUMNS / total_segment_count : division by 0 (error token is "total_segment_count ")

To Reproduce
Steps to reproduce the behavior:

  1. comment out old sbp
  2. install new sbp via homebrew
  3. add new sbp path to .bashrc
  4. run sbp reload, see error

Expected behavior
sbp prompt loads

Environment (please complete the following information):

  • OS: Mac OS 10.15.7
  • Terminal iTerm2
  • Version 3.4.0 beta9
@pulberg pulberg added the bug label Sep 28, 2020
@brujoand
Copy link
Owner

oh, that's weird. And also dividing by the total segment count without checking for 0 is bad. :/ You do have segments defined in you config I assume? And this happens in a new shell too?

@pulberg
Copy link
Author

pulberg commented Sep 29, 2020

This is a "new" sbp install, so everything is as it was delivered, no changes to config/etc.

sbp list config
SEGMENTS_AWS_COLOR_PRIMARY                  196
SEGMENTS_AWS_COLOR_SECONDARY                172
SEGMENTS_COMMAND_COLOR_PRIMARY              250
SEGMENTS_COMMAND_COLOR_PRIMARY_HIGHLIGHT    196
SEGMENTS_COMMAND_COLOR_SECONDARY            238
SEGMENTS_COMMAND_COLOR_SECONDARY_HIGHLIGHT  250
SEGMENTS_CONDA_COLOR_PRIMARY                196
SEGMENTS_CONDA_COLOR_SECONDARY              172
SEGMENTS_GIT_COLOR_PRIMARY                  148
SEGMENTS_GIT_COLOR_SECONDARY                238
SEGMENTS_GIT_ICON
SEGMENTS_GIT_INCOMING_ICON                  ↓
SEGMENTS_GIT_OUTGOING_ICON                  ↑
SEGMENTS_HOST_COLOR_PRIMARY                 8
SEGMENTS_HOST_COLOR_PRIMARY_HIGHLIGHT       172
SEGMENTS_HOST_COLOR_SECONDARY               251
SEGMENTS_HOST_COLOR_SECONDARY_HIGHLIGHT     0
SEGMENTS_K8S_COLOR_PRIMARY                  244
SEGMENTS_K8S_COLOR_SECONDARY                15
SEGMENTS_K8S_DEFAULT_USER                   pulberg
SEGMENTS_K8S_HIDE_CLUSTER                   0
SEGMENTS_LOAD_COLOR_PRIMARY                 172
SEGMENTS_LOAD_COLOR_PRIMARY_HIGHLIGHT       196
SEGMENTS_LOAD_COLOR_SECONDARY               238
SEGMENTS_LOAD_COLOR_SECONDARY_HIGHLIGHT     15
SEGMENTS_LOAD_THRESHOLD                     50
SEGMENTS_LOAD_THRESHOLD_HIGH                80
SEGMENTS_PATH_COLOR_PRIMARY                 31
SEGMENTS_PATH_COLOR_SECONDARY               15
SEGMENTS_PATH_COLOR_SPLITTER                250
SEGMENTS_PATH_RO_COLOR_PRIMARY              238
SEGMENTS_PATH_RO_COLOR_SECONDARY            99
SEGMENTS_PATH_SPLITTER_DISABLE              1
SEGMENTS_PROMPT_READY_COLOR_PRIMARY
SEGMENTS_PROMPT_READY_COLOR_SECONDARY       250
SEGMENTS_PROMPT_READY_ICON                  ➜
SEGMENTS_PYTHON_ENV_COLOR_PRIMARY           172
SEGMENTS_PYTHON_ENV_COLOR_SECONDARY         99
SEGMENTS_RESCUETIME_COLOR_PRIMARY           22
SEGMENTS_RESCUETIME_COLOR_SECONDARY         250
SEGMENTS_RESCUETIME_COLOR_SPLITTER          15
SEGMENTS_RESCUETIME_REFRESH_RATE            600
SEGMENTS_RETURN_CODE_COLOR_PRIMARY          238
SEGMENTS_RETURN_CODE_COLOR_SECONDARY        99
SEGMENTS_TIMESTAMP_COLOR_PRIMARY            8
SEGMENTS_TIMESTAMP_COLOR_SECONDARY          251
SEGMENTS_TIMESTAMP_FORMAT                   %H:-%M:-%S
SEGMENTS_WTTR_COLOR_PRIMARY                 22
SEGMENTS_WTTR_COLOR_SECONDARY               250
SEGMENTS_WTTR_COLOR_SPLITTER                15
SEGMENTS_WTTR_FORMAT                        %p;%t;%w
SEGMENTS_WTTR_LOCATION                      Oslo
sbp list segments
aws:           disabled  10ms
command:       disabled  14ms
conda:         disabled  13ms
exit_code:     disabled  11ms
git:           disabled  11ms
host:          disabled  19ms
k8s:           disabled  24ms
load:          disabled  37ms
path:          disabled  15ms
path_ro:       disabled  14ms
prompt_ready:  disabled  14ms
python_env:    disabled  12ms
rescuetime:    disabled  14ms
timestamp:     disabled  18ms
wttr:          disabled  20ms

@brujoand
Copy link
Owner

Right, so I'm guessing for some reason your local config wasn't created. is $HOME/.config/sbp/ populated at all?

@brujoand
Copy link
Owner

brujoand commented Sep 30, 2020

It would be interesting to see what happens if you set export SBP_SEGMENTS_LEFT=('path' 'python_env' 'git' 'command') directly in the shell

@pulberg
Copy link
Author

pulberg commented Oct 3, 2020

Right, so I'm guessing for some reason your local config wasn't created. is $HOME/.config/sbp/ populated at all?

480 B  Thu Aug 27 15:28:58 2020  ../
 96 B  Mon Sep 28 13:14:53 2020  cache/
1.5 KB Wed Jan 15 08:48:59 2020  colors.conf*
1.3 KB Tue Sep 29 08:09:58 2020  hook.log
2.4 KB Fri Feb  9 16:49:27 2018  sbp.conf*
1.1 KB Wed Jan 15 08:48:59 2020  settings.conf*

@pulberg
Copy link
Author

pulberg commented Oct 3, 2020

It would be interesting to see what happens if you set export SBP_SEGMENTS_LEFT=('path' 'python_env' 'git' 'command') directly in the shell

Nothing happens running the export, and sbp reload has same error -

export SBP_SEGMENTS_LEFT=('path' 'python_env' 'git' 'command')
pulberg@myawesomemachine:~$ sbp reload
/usr/local/opt/sbp/src/main.bash: line 30: COLUMNS / total_segment_count : division by 0 (error token is "total_segment_count ")

@pulberg
Copy link
Author

pulberg commented Oct 6, 2020

I removed $HOME/.config/sbp/, restarted the terminal, typed sbp reload and had it rebuild the config, everything working correctly now.

@brujoand
Copy link
Owner

brujoand commented Oct 6, 2020

That's really odd. What does the '*' mean at the file listing you posted 3 days ago btw? Is that symlinks or some permission indicator?
Anyway, thanks for reporting back 👍

@pulberg
Copy link
Author

pulberg commented Oct 6, 2020

Ok, i'm still off on something, this doesn't make sense (i'll open a new issue if you'd like)

sbp status says my layout is powerline, but looking at it you can clearly see that it's not. Also, each new iTerm tab I open does not have my colors or layout set, this used to work, what am I missing?

pulberg@myawesomemachine:~$ sbp status
- _____________________________
 /   _____/\______   \______   \
 \_____  \  |    |  _/|     ___/
 /        \ |    |   \|    |
/_______  / |______  /|____|
        \/         \/
Color: monokai
Layout: powerline

Current colors:
      0    1    2    3    4    5    6    7    8    9    10    11    12    13    14    15  
pulberg@myawesomemachine:~$

@brujoand
Copy link
Owner

brujoand commented Oct 7, 2020

Yeah, this appears to be the plain layout. Did you install both through git and through homebrew? The weird thing to me is that if SBP couldn't read the config, it should complain and try to recreate it. If it does find it, it should use it, or fall back to plain if nothing is set. But the fact that sbp status gives powerline, but the prompt displays plain is super weird. What happens if you try setting the layout interactively? sbp set layout powerline

@akinomyoga
Copy link
Contributor

Today I encountered the same problem when I updated sbp after two-year blank. It was fixed by removing ~/.config/sbp and reloading sbp. I have checked the differences of the configuration and found that all the configuration variables of the name settings_* have been renamed to SBP_SEGMENTS_* or SEGMENTS_*, etc. In particular, the change related to division by 0 error reported here is as follows:

diff -bwur /home/murase/.config/sbp.bk/settings.conf /home/murase/.config/sbp/settings.conf
--- /home/murase/.config/sbp.bk/settings.conf^I2019-12-29 21:03:05.673117814 +0900
+++ /home/murase/.config/sbp/settings.conf^I2022-01-20 18:17:46.564313860 +0900
@@ -1,33 +1,33 @@

[...]

-# a multiplexer?
-if [[ "$TERM" = "screen" || -n "$TMUX" ]]; then
-  # We're inside tmux or screen
-  settings_segments_left=('path' 'python_env' 'git' 'commend')
-  settings_segments_right=('')
+# a small window?
+
+if [[ "$COLUMNS" -le 120 ]]; then
+  # Let's adjust to the smaller screen
+  SBP_THEME_LAYOUT='lines'
+  SBP_SEGMENTS_LEFT=('path' 'python_env' 'git' 'command')
 else
-  settings_segments_left=('host' 'path' 'python_env' 'git' )
-  settings_segments_right=('command' 'timestamp')
+  SBP_SEGMENTS_LEFT=('host' 'path' 'python_env' 'k8s' 'git' 'nix')
+  SBP_SEGMENTS_RIGHT=('command' 'timestamp')
+  SBP_SEGMENTS_LINE_TWO=('prompt_ready')
 fi

I think sbp should check whether the loaded configuration contains deprecated settings and should instruct users how to do the migration of the configuration when it detects the deprecated settings.

@brujoand
Copy link
Owner

I think sbp should check whether the loaded configuration contains deprecated settings and should instruct users how to do the migration of the configuration when it detects the deprecated settings.

Agreed, I actually thought that was in place for this use case. :/

@akinomyoga
Copy link
Contributor

akinomyoga commented Jan 20, 2022

Agreed, I actually thought that was in place for this use case. :/

Thanks. I've identified that the change was introduced in 3c9b999f, but there don't seem to be any codes trying to detect the deprecated settings in src/configure.bash then. After that, the file was updated three times in 2bd1888b, 3e2eba8f and e99a1b74, but I don't see any changes that check the deprecated settings.

I guess the change introduced in e99a1b74 tries to fill missing configurations. But actually, the current config/settings.conf does not define arrays SBP_SEGMENTS_{LEFT,RIGHT}, etc. even if they are not defined.

@akinomyoga
Copy link
Contributor

akinomyoga commented Jan 20, 2022

@brujoand Maybe I can create a PR to resolve this issue.

What is the minimal Bash version that sbp supports? (-> OK, I found it in README.md---Bash 4.3---) The feature set that I can use in the PR depends on the minimal Bash version supported by sbp.

@muktadirmaashif
Copy link

I encountered this error when I maximized my terminal window. Later I found that I edited my ~/.config/sbp/settings.conf file and I deleted the lines inside the if condition where small screen adjustment was made. That's why it worked when the width is less than equal half my workspace.
What I did was commented out the condition and fixed the prompt without mentioning window size. How it was helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants