pls-rs / pls

`pls` is a prettier and powerful `ls(1)` for the pros.
https://pls.cli.rs/
GNU General Public License v3.0
830 stars 24 forks source link

Error when listing files on Windows #71

Closed jnunderwood closed 1 year ago

jnunderwood commented 1 year ago

Description

When I run pls on Windows (for a certain directory), I get a stack trace.

Reproduction

  1. Running PowerShell as an administrator, install gsudo, specifically via chocolatey:
    $ choco install gsudo
  2. Run pls:
    $ pls C:\tools\gsudo\
  3. See error.
    Traceback (most recent call last):
     File "<frozen runpy>", line 198, in _run_module_as_main
     File "<frozen runpy>", line 88, in _run_code
     File "C:\Users\junderwo\AppData\Roaming\Python\Python311\Scripts\pls.exe\__main__.py", line 7, in <module>
     File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\pls\main.py", line 162, in main
       main_unit(node, show_header)
     File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\pls\main.py", line 143, in main_unit
       printer.print(show_header)
     File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\pls\output\printers.py", line 32, in print
       self.print_output()
     File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\pls\output\table_printer.py", line 139, in print_output
       self.console.print(self.table)
     File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\rich\console.py", line 1694, in print
       extend(render(renderable, render_options))
     File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\rich\console.py", line 1326, in render
       for render_output in iter_render:
     File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\rich\table.py", line 484, in __rich_console__
       widths = self._calculate_column_widths(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\rich\table.py", line 525, in _calculate_column_widths
       width_ranges = [
                      ^
     File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\rich\table.py", line 526, in <listcomp>
       self._measure_column(console, options, column) for column in columns
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\rich\table.py", line 729, in _measure_column
       _min, _max = get_render_width(console, options, cell.renderable)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\rich\measure.py", line 109, in get
       get_console_width(console, options)
     File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\rich\padding.py", line 132, in __rich_measure__
       measure_min, measure_max = Measurement.get(console, options, self.renderable)
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\rich\measure.py", line 99, in get
       renderable = console.render_str(
                    ^^^^^^^^^^^^^^^^^^^
     File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\rich\console.py", line 1424, in render_str
       rich_text = render_markup(
                   ^^^^^^^^^^^^^^
     File "C:\Users\junderwo\AppData\Roaming\Python\Python311\site-packages\rich\markup.py", line 168, in render
       raise MarkupError(
    rich.errors.MarkupError: closing tag '[/]' at position 61 has nothing to close

Expectation

I expect to see a formatted list of the directory...

  Permissions   Size   Modified at                Name
d rwx rwx rwx   -      2023-05-04 07:51:49       Current/
d rwx rwx rwx   -      2023-05-04 07:51:56       v2.0.9/

Environment

Additional context

I installed pls using this command: pip install --upgrade --user pls. This is what my directory looks like using ls:

$ ls

    Directory: C:\tools\gsudo

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
l----            5/4/2023  6:44 AM                Current -> C:\tools\gsudo\v2.0.9\
d----            5/4/2023  6:44 AM                v2.0.9
dhruvkb commented 1 year ago

@jnunderwood It's hard for me to reproduce this because I do not have a Windows machine. Are you seeing this error in any other directory besides C:\tools\gsudo\?

jnunderwood commented 1 year ago

So far, only that specific directory. And only if I install the gsudo package using chocolatey. I have tried recreating the directory manually and pls works just fine. It is very strange. Please let me know if I can help at all. Thanks.

dhruvkb commented 1 year ago

Closing because of the rewrite.