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

ranger crashes when deleting the .git folder of the current folder #2932

Open
vonshednob opened this issue Jan 3, 2024 · 4 comments
Open

Comments

@vonshednob
Copy link

Runtime Environment

  • Operating system and version: manjaro
  • Terminal emulator and version: foot version 1.16.2
  • Python version: 3.11.6
  • Ranger version/commit: 1.9.3, 136416c
  • Locale: en_US.UTF-8

Current Behavior

ranger crashes when deleting a .git folder.

Expected Behavior

ranger should not crash.

Context

I was trying to delete a .git folder.

Steps to reproduce

  1. Copy any git controlled repository someplace
  2. Enter the folder and show hidden files (zh)
  3. Select and delete the .git folder (dDy)
  4. Select the next file or otherwise move around in the folder

Traceback

Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/ranger/core/main.py", line 214, in main
    fm.loop()
  File "/usr/lib/python3.11/site-packages/ranger/core/fm.py", line 417, in loop
    ui.redraw()
  File "/usr/lib/python3.11/site-packages/ranger/gui/ui.py", line 343, in redraw
    self.draw()
  File "/usr/lib/python3.11/site-packages/ranger/gui/ui.py", line 370, in draw
    DisplayableContainer.draw(self)
  File "/usr/lib/python3.11/site-packages/ranger/gui/displayable.py", line 268, in draw
    displayable.draw()
  File "/usr/lib/python3.11/site-packages/ranger/gui/widgets/statusbar.py", line 110, in draw
    self._calc_bar()
  File "/usr/lib/python3.11/site-packages/ranger/gui/widgets/statusbar.py", line 115, in _calc_bar
    self._get_left_part(bar)
  File "/usr/lib/python3.11/site-packages/ranger/gui/widgets/statusbar.py", line 202, in _get_left_part
    vcsinfo = '({0:s}: {1:s})'.format(
              ^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: unsupported format string passed to NoneType.__format__
@veyfera
Copy link

veyfera commented Jan 8, 2024

Hello, vonshednob. Could not reproduce your issue using manjaro, kde, foot

@vonshednob
Copy link
Author

Thanks for trying. Weirdly enough -- I cannot reproduce this anymore either. It must have been some other specific circumstance. 🤔

I guess it's safe to close this issue until a better reproduction scenario comes up.

@yagarea
Copy link

yagarea commented Mar 18, 2024

I am experiencing same issue. this is log:

ranger version: ranger-master
Python version: 3.11.8 (main, Feb 12 2024, 14:50:05) [GCC 13.2.1 20230801]
Locale: en_US.UTF-8
Current file: '/home/john/Web/klarka/_data'

Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/ranger/core/main.py", line 214, in main
    fm.loop()
  File "/usr/lib/python3.11/site-packages/ranger/core/fm.py", line 417, in loop
    ui.redraw()
  File "/usr/lib/python3.11/site-packages/ranger/gui/ui.py", line 343, in redraw
    self.draw()
  File "/usr/lib/python3.11/site-packages/ranger/gui/ui.py", line 370, in draw
    DisplayableContainer.draw(self)
  File "/usr/lib/python3.11/site-packages/ranger/gui/displayable.py", line 268, in draw
    displayable.draw()
  File "/usr/lib/python3.11/site-packages/ranger/gui/widgets/statusbar.py", line 110, in draw
    self._calc_bar()
  File "/usr/lib/python3.11/site-packages/ranger/gui/widgets/statusbar.py", line 115, in _calc_bar
    self._get_left_part(bar)
  File "/usr/lib/python3.11/site-packages/ranger/gui/widgets/statusbar.py", line 202, in _get_left_part
    vcsinfo = '({0:s}: {1:s})'.format(
              ^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: unsupported format string passed to NoneType.__format__

ranger crashed. Please report this traceback at:
https://github.com/ranger/ranger/issues

@lkschu
Copy link

lkschu commented Apr 5, 2024

Yes, this is a bug. To reproduce it, vcs_aware has to be set to true in rc.conf.

Here is a quick and dirty way to fix the crash. In ranger/gui/widgets/statusbar.py line 200

-    if directory.vcs and directory.vcs.track:
+    if directory.vcs and directory.vcs.track and directory.vcs.rootvcs.repotype:

I think the problem comes from the lazy evaluation (and caching?) of vcs(self) in ranger/container/directory/py.
Using a normal python property instead of the lazy_property would fix the problem but would disable the option to disable vcs_aware while ranger is running. At least if I am reading this correctly.

-    @lazy_property
+    @property
     def vcs(self):
-        if not self._vcs_signal_handler_installed:
-            self.settings.signal_bind(
-                'setopt.vcs_aware', self.vcs__reset,  # pylint: disable=no-member
-                weak=True, autosort=False,
-            )
-            self._vcs_signal_handler_installed = True
         if self.settings.vcs_aware:
             return Vcs(self)
         return None

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

No branches or pull requests

4 participants