Thefuck: UnicodeDecodeError when using thefuck

Created on 26 Oct 2019  Â·  6Comments  Â·  Source: nvbn/thefuck

I followed the alias guide, but I got an error when running thefuck in PowerShell:

Traceback (most recent call last):
  File "d:\python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "d:\python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\Python36\Scripts\thefuck.exe\__main__.py", line 9, in <module>
  File "d:\python36\lib\site-packages\thefuck\entrypoints\main.py", line 26, in main
    fix_command(known_args)
  File "d:\python36\lib\site-packages\thefuck\entrypoints\fix_command.py", line 36, in fix_command
    command = types.Command.from_raw_script(raw_command)
  File "d:\python36\lib\site-packages\thefuck\types.py", line 82, in from_raw_script
    output = get_output(script, expanded)
  File "d:\python36\lib\site-packages\thefuck\output_readers\__init__.py", line 20, in get_output
    return rerun.get_output(script, expanded)
  File "d:\python36\lib\site-packages\thefuck\output_readers\rerun.py", line 62, in get_output
    output = result.stdout.read().decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb2 in position 9: invalid start byte
hacktoberfest help wanted

Most helpful comment

Hey, can I look into this issue?

All 6 comments

@nvbn would this be easier if we decode the output = result.stdout.read().decode('utf-8') using utf-32 instead of utf-8 ?

Hey, can I look into this issue?

@Surya97, you are more than welcome! The Fuck really needs Windows users as contributors!

Maybe we can using chardet to make it?

I'm not sure to open a new issue since this is also open for ubuntu. I get the same proble wiht MAC OS X catalina. installed with homebrew and usd with a zsh plugin.

It generally worked well i.e.:

~ via ⬢ v12.4.0
➜ ls -j
ls: illegal option -- j
usage: ls [-@ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1%] [file ...]

~ via ⬢ v12.4.0
➜ fuck
ls -k [enter/↑/↓/ctrl+c]

but when I use a spanish character, for example in my keyboard ñ is near to l, so I cant type easily,
ls -ñ instead of ls -l (Really normaly not happens, but in this case I was thinking for an option than doesnt have ls)

so I tried with this:

~ via ⬢ v12.4.0 took 8s
➜ ls -ñ
ls: illegal option -- �
usage: ls [-@ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1%] [file ...]

~ via ⬢ v12.4.0
➜ fuck
Traceback (most recent call last):
  File "/usr/local/bin/thefuck", line 13, in <module>
    sys.exit(main())
  File "/usr/local/Cellar/thefuck/3.30/libexec/lib/python3.8/site-packages/thefuck/entrypoints/main.py", line 31, in main
    fix_command(known_args)
  File "/usr/local/Cellar/thefuck/3.30/libexec/lib/python3.8/site-packages/thefuck/entrypoints/fix_command.py", line 36, in fix_command
    command = types.Command.from_raw_script(raw_command)
  File "/usr/local/Cellar/thefuck/3.30/libexec/lib/python3.8/site-packages/thefuck/types.py", line 82, in from_raw_script
    output = get_output(script, expanded)
  File "/usr/local/Cellar/thefuck/3.30/libexec/lib/python3.8/site-packages/thefuck/output_readers/__init__.py", line 20, in get_output
    return rerun.get_output(script, expanded)
  File "/usr/local/Cellar/thefuck/3.30/libexec/lib/python3.8/site-packages/thefuck/output_readers/rerun.py", line 63, in get_output
    output = result.stdout.read().decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 in position 22: invalid continuation byte

~ via ⬢ v12.4.0
➜ locale
LANG="es_ES.UTF-8"
LC_COLLATE="es_ES.UTF-8"
LC_CTYPE="es_ES.UTF-8"
LC_MESSAGES="es_ES.UTF-8"
LC_MONETARY="es_ES.UTF-8"
LC_NUMERIC="es_ES.UTF-8"
LC_TIME="es_ES.UTF-8"
LC_ALL=

to be fear I think that I have my locale well configured, but also ls doesn't catch ñ, but in environment varianles it works, it seems that ls only handles ascii internally?.

Thanks for this nice library for console use.

This is the output Python gets:

b'ls: illegal option -- \xc3\nusage: ls [-@ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1%] [file ...]\n'

And indeed, \n is not a valid continuation for \xc3. That's very odd. 🤔

Was this page helpful?
0 / 5 - 0 ratings

Related issues

griffinqiu picture griffinqiu  Â·  4Comments

zixuanweeei picture zixuanweeei  Â·  5Comments

steve02081504 picture steve02081504  Â·  5Comments

disjunto picture disjunto  Â·  6Comments

shelbyKiraM picture shelbyKiraM  Â·  5Comments