# Buggy code
def enter_dir(self, path, history=True):
    """Enter given path"""
    # TODO: Ensure that there is always a self.thisdir
    if path is None:
        return None
    path = str(path)

    # clear filter in the folder we're leaving
    if self.fm.settings.clear_filters_on_dir_change and self.thisdir:
        self.thisdir.filter = None
        self.thisdir.refilter()

    previous = self.thisdir

    # get the absolute path
    path = normpath(join(self.path, expanduser(path)))

    if not isdir(path):
        return False
    new_thisdir = self.fm.get_directory(path)

    try:
        os.chdir(path)
    except OSError:
        return True
    self.path = path
    self.thisdir = new_thisdir

    self.thisdir.load_content_if_outdated()

    # build the pathway, a tuple of directory objects which lie
    # on the path to the current directory.
    if path == "/":
        self.pathway = (self.fm.get_directory("/"),)
    else:
        pathway = []
        currentpath = "/"
        for comp in path.split("/"):
            currentpath = join(currentpath, comp)
            pathway.append(self.fm.get_directory(currentpath))
        self.pathway = tuple(pathway)

    self.assign_cursor_positions_for_subdirs()

    # set the current file.
    self.thisdir.sort_directories_first = self.fm.settings.sort_directories_first
    self.thisdir.sort_reverse = self.fm.settings.sort_reverse
    self.thisdir.sort_if_outdated()
    if previous and previous.path != path:
        self.thisfile = self.thisdir.pointed_obj
    else:
        # This avoids setting self.pointer (through the 'move' signal) and
        # is required so that you can use enter_dir when switching tabs
        # without messing up the pointer.
        self._thisfile = self.thisdir.pointed_obj

    if history:
        self.history.add(new_thisdir)

    self.fm.signal_emit("cd", previous=previous, new=self.thisdir)

    return True


# Traceback (AttributeError)
$ ranger/ranger.py ~/.config/neofetch/config.conf
ranger version: ranger-master 1.9.2
Python version: 2.7.15+ (default, Oct  2 2018, 22:12:08) [GCC 8.2.0]
Locale: None.None

Traceback (most recent call last):
File "/home/techtonik/p/ranger/ranger/core/main.py", line 195, in main
fm.loop()
File "/home/techtonik/p/ranger/ranger/core/fm.py", line 398, in loop
ui.redraw()
File "/home/techtonik/p/ranger/ranger/gui/ui.py", line 342, in redraw
self.finalize()
File "/home/techtonik/p/ranger/ranger/gui/ui.py", line 397, in finalize
DisplayableContainer.finalize(self)
File "/home/techtonik/p/ranger/ranger/gui/displayable.py", line 264, in finalize
displayable.finalize()
File "/home/techtonik/p/ranger/ranger/gui/widgets/view_base.py", line 60, in finalize
- self.main_column.scroll_begin
AttributeError: 'NoneType' object has no attribute 'pointer'

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

# Fixed code
def enter_dir(self, path, history=True):
    """Enter given path"""
    # TODO: Ensure that there is always a self.thisdir
    if path is None:
        return None
    path = str(path)

    # clear filter in the folder we're leaving
    if self.fm.settings.clear_filters_on_dir_change and self.thisdir:
        self.thisdir.filter = None
        self.thisdir.refilter()

    previous = self.thisdir

    # get the absolute path
    path = normpath(join(self.path, expanduser(path)))
    selectfile = None

    if not isdir(path):
        selectfile = path
        path = dirname(path)
    new_thisdir = self.fm.get_directory(path)

    try:
        os.chdir(path)
    except OSError:
        return True
    self.path = path
    self.thisdir = new_thisdir

    self.thisdir.load_content_if_outdated()

    # build the pathway, a tuple of directory objects which lie
    # on the path to the current directory.
    if path == "/":
        self.pathway = (self.fm.get_directory("/"),)
    else:
        pathway = []
        currentpath = "/"
        for comp in path.split("/"):
            currentpath = join(currentpath, comp)
            pathway.append(self.fm.get_directory(currentpath))
        self.pathway = tuple(pathway)

    self.assign_cursor_positions_for_subdirs()

    # set the current file.
    self.thisdir.sort_directories_first = self.fm.settings.sort_directories_first
    self.thisdir.sort_reverse = self.fm.settings.sort_reverse
    self.thisdir.sort_if_outdated()
    if selectfile:
        self.thisdir.move_to_obj(selectfile)
    if previous and previous.path != path:
        self.thisfile = self.thisdir.pointed_obj
    else:
        # This avoids setting self.pointer (through the 'move' signal) and
        # is required so that you can use enter_dir when switching tabs
        # without messing up the pointer.
        self._thisfile = self.thisdir.pointed_obj

    if history:
        self.history.add(new_thisdir)

    self.fm.signal_emit("cd", previous=previous, new=self.thisdir)

    return True