Strange Segment error in certain directories
I've been using Powerline for a little while now but just today I noticed that the PS1 freaks out in certain directories.
Specifically I get the following:
Exception in thread Thread-1:
Traceback (most recent call last):
File "/home/wms_joe/bin/miniconda2/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "build/bdist.linux-x86_64/egg/powerline_shell/segments/git.py", line 68, in run
self.stats, self.branch = build_stats()
File "build/bdist.linux-x86_64/egg/powerline_shell/segments/git.py", line 55, in build_stats
branch_info = parse_git_branch_info(status)
File "build/bdist.linux-x86_64/egg/powerline_shell/segments/git.py", line 7, in parse_git_branch_info
info = re.search('^## (?P<local>\S+?)''(\.{3}(?P<remote>\S+?)( \[(ahead (?P<ahead>\d+)(, )?)?(behind (?P<behind>\d+))?\])?)?$', status[0])
IndexError: list index out of range
Traceback (most recent call last):
File "/home/wms_joe/bin/miniconda2/bin/powerline-shell", line 9, in <module>
load_entry_point('powerline-shell==0.5.4', 'console_scripts', 'powerline-shell')()
File "build/bdist.linux-x86_64/egg/powerline_shell/__init__.py", line 224, in main
File "build/bdist.linux-x86_64/egg/powerline_shell/segments/git.py", line 72, in add_to_powerline
AttributeError: 'Segment' object has no attribute 'stats'
And this happens inside my git repository that resides here:
https://github.com/jrjhealey/MultiGeneBlastParser
However, if I clone that repo on my mac locally, everything is fine. If I cd in to that directory on a Ubuntu server however I get the above error. cd-ing back in to another directory restores the powerline. Other git repos on the same Ubuntu box work without issue however.
I've deleted the repo and recloned it on the Ubuntu machine and the same problem appears.
Both systems are using Bash as the shell.
Any ideas?
I've discovered that the segment errors will disappear so long as the directory contains a .gitignore file, even if it is empty; touch .gitignore inside the repo folder is sufficient.
Hello, please reopen the issue I have the .gitignore file but the error persist:
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
self.run()
File "build/bdist.linux-x86_64/egg/powerline_shell/segments/git.py", line 68, in run
self.stats, self.branch = build_stats()
File "build/bdist.linux-x86_64/egg/powerline_shell/segments/git.py", line 55, in build_stats
branch_info = parse_git_branch_info(status)
File "build/bdist.linux-x86_64/egg/powerline_shell/segments/git.py", line 7, in parse_git_branch_info
info = re.search('^## (?P<local>\S+?)''(\.{3}(?P<remote>\S+?)( \[(ahead (?P<ahead>\d+)(, )?)?(behind (?P<behind>\d+))?\])?)?$', status[0])
IndexError: list index out of range
Traceback (most recent call last):
File "/home/santiago.maturana/.local/bin/powerline-shell", line 11, in <module>
load_entry_point('powerline-shell==0.7.0', 'console_scripts', 'powerline-shell')()
File "build/bdist.linux-x86_64/egg/powerline_shell/__init__.py", line 240, in main
File "build/bdist.linux-x86_64/egg/powerline_shell/segments/git.py", line 72, in add_to_powerline
AttributeError: 'Segment' object has no attribute 'stats'
When git status shows no changes and no untracked there is the bug, but when I have any change bug gone. And when shows git segment insted the branch name shows strange version number mixed with last commit hash.
Thanks for adding to this, I’ve discovered the same thing. Some logic for handling just the situation when a repo is unmodified should be all that’s needed.
This started happening today for me, too. But with svn instead of git:
Exception in thread Thread-3:
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.6/dist-packages/powerline_shell/segments/svn.py", line 54, in run
self.stats, self.revision = build_stats()
File "/usr/local/lib/python3.6/dist-packages/powerline_shell/segments/svn.py", line 48, in build_stats
revision = _get_svn_revision()
File "/usr/local/lib/python3.6/dist-packages/powerline_shell/segments/svn.py", line 14, in _get_svn_revision
return revision
UnboundLocalError: local variable 'revision' referenced before assignment
Traceback (most recent call last):
File "/usr/local/bin/powerline-shell", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python3.6/dist-packages/powerline_shell/__init__.py", line 240, in main
segment.add_to_powerline()
File "/usr/local/lib/python3.6/dist-packages/powerline_shell/segments/svn.py", line 58, in add_to_powerline
if not self.stats:
AttributeError: 'Segment' object has no attribute 'stats'
So I removed the "svn", entry from my config.json, and then issue #343 started happening. After adding @eightnoteight's fix export PYTHONIOENCODING='utf8', the powerline works again.
But even with the export, adding "svn" to the config breaks powerline, so please don't close the issue yet.
Edit: I forgot to add, this appears to be happening regardless of folder, and since it's happening with svn instead of git for me, it's regardless of .gitignore file.
I'm still seeing this issue.
@b-ryan: Here's a pretty harmless change which I think (but haven't verified) should fix the issue: https://github.com/b-ryan/powerline-shell/issues/408