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

UnicodeDecodeError: 'utf-8' codec can't decode byte (Windows CHCP check) #74

Open
InfoSCE opened this issue Jul 1, 2021 · 2 comments
Open
Labels
bug Something isn't working

Comments

@InfoSCE
Copy link

InfoSCE commented Jul 1, 2021

Hi,

I recently discover your third-party for rclone and i really enjoy it.
I just want to share with you my experience when i tried to run for the first time rclonesync on my server.
I read your documentation and configured properly my rclone's remote in version 1.55 and installed Python 3.9.6.
I've seen i needed in Windows environnement to set "chcp to 65001" and "set PYTHONIONECODING=UTF-8" before i can run my first sync.
I did it.
But, when i launched my command

rclonesync -1 C:\xxx\ remote:folder

I got this error :

File "E:\RClone\v1.55_x64\rclonesync.py", line 801, in <module>
chcp = subprocess.check_output(["chcp"], shell=True).decode("utf-8")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 20: invalid start byte

I've tried to understand why, so i checked my chcp and PYTHONIOENCODING values, all good.
I opened rclonesync file with Python IDLE and i gone to line 801 :

chcp = subprocess.check_output(["chcp"], shell=True).decode("utf-8")

I've tried to run that line in python's console, same error.
So, I ran the first part before "decode("utf-8)" and i got that :

b'Page de codes active\xff: 65001\r\n'

You can see the xff part which seems to generate an error.
To avoid this i added an ignore argument in the command line and it works perfectly.

chcp = subprocess.check_output(["chcp"], shell=True).decode("utf-8","ignore")

But the error is still there, so if you have solution for me, i take it with pleasure :)

Thank you... and sorry for my english ;)

Damien

@cjnaz
Copy link
Owner

cjnaz commented Jul 1, 2021

Thanks for the bug report, @InfoSCE.

Since my system uses English, I seldom run into utf-8 encoding, and it is difficult for me to do any debug and verification. I don't understand how to control the Windows command response so that it only returns utf-8 encoding versus codes such as 0xff. Your solution looks good for this specific error.

Note that there may be cases where you have file names that contain non-utf-8 characters and rclonesync may error out on these as well.

I will leave this issue open for others to find, if needed. Note that there is a beta version of rclone that incorporates rclonesync directly as bisync. This new rclone will replace rclonesync hopefully later this year. As such, I'm doing only critical bug fixes on rclonesync.

@cjnaz cjnaz added the bug Something isn't working label Jul 1, 2021
@cjnaz
Copy link
Owner

cjnaz commented Jul 1, 2021

This error (fixed with the .decode("utf-8","ignore")) would come up in all runs, not just the first sync. I've updated the issue title.

@cjnaz cjnaz changed the title First run : UnicodeDecodeError: 'utf-8' codec can't decode byte UnicodeDecodeError: 'utf-8' codec can't decode byte (Windows CHCP check) Jul 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants