each time I run fuck in my powershell prompt, I get warned about mismatched stdin and stdout encodings:
c:\python34\lib\site-packages\win_unicode_console__init__.py:27: RuntimeWarning: sys.stdin.encoding == 'utf-8', whereas sys.stdout.encoding == 'cp1252', readline hook consumer may assume they are the same
readline_hook.enable(use_pyreadline=use_pyreadline)
I saw issue #486, but this issue is slightly different (the encoding isn't 'None').
I see this as well. There are two options I've come up with, but I don't fully understand the ramifications of doing so. One is:
diff --git a/thefuck/system/win32.py b/thefuck/system/win32.py
index a8b6c0a..6d6fa0a 100644
--- a/thefuck/system/win32.py
+++ b/thefuck/system/win32.py
@@ -7,7 +7,7 @@ from .. import const
def init_output():
import colorama
- win_unicode_console.enable()
+ win_unicode_console.enable(use_readline_hook = False)
colorama.init()
Which works on my system (Windows 10 + PowerShell), but I don't know enough about win_unicode_console to know if it is correct.
The safer but hack-ish way is to just ignore the warning
diff --git a/thefuck/system/win32.py b/thefuck/system/win32.py
index a8b6c0a..a38c584 100644
--- a/thefuck/system/win32.py
+++ b/thefuck/system/win32.py
@@ -3,14 +3,15 @@ import sys
import msvcrt
import win_unicode_console
from .. import const
+import warnings
def init_output():
import colorama
- win_unicode_console.enable()
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore")
+ win_unicode_console.enable()
colorama.init()
Let me know how I can help with a fix here as this is the last bug I run into using thefuck with PowerShell. Thanks!
I fixed this by setting $env:PYTHONIOENCODING='utf-8' in my $PROFILE
FYI, this is documented https://github.com/nvbn/thefuck/wiki/Shell-aliases#powershell so this issue can likely be closed
@nvbn Thanks for this!
FYI - I had neglected to put the fuck alias in my PS profile which is how I found this thread but it gave me slightly wrong instructions. The "More details" link should be the one mentioned above https://github.com/nvbn/thefuck/wiki/Shell-aliases#powershell. Maybe also mentioning placing $env:PYTHONIOENCODING='utf-8' before the fuck alias would also be helpful.
Seems like fuck alias isn't configured!
Please put iex "$(thefuck --alias)" in your $profile and apply changes with . $profile or restart your shell.
More details - https://github.com/nvbn/thefuck#manual-installation
Most helpful comment
I fixed this by setting
$env:PYTHONIOENCODING='utf-8'in my $PROFILE