frej / fast-export

A mercurial to git converter using git-fast-import
http://repo.or.cz/w/fast-export.git
808 stars 255 forks source link

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 13: ordinal not in range(128) #239

Closed jaideejung007 closed 4 years ago

jaideejung007 commented 4 years ago

Using OS: Ubuntu 20.4 Python 2

Error on Execute hg-fast-export hg-fast-export.sh -r <local-repo>

Traceback (most recent call last): File "/home/anusuk/พื้นโต๊ะ/fast-export/hg-fast-export.py", line 726, in plugins=plugins_dict)) File "/home/anusuk/พื้นโต๊ะ/fast-export/hg-fast-export.py", line 536, in hg2git ui,repo=setup_repo(repourl) File "/home/anusuk/พื้นโต๊ะ/fast-export/hg2git.py", line 47, in setup_repo return myui,hg.repository(myui, fsencode(url)).unfiltered() File "/home/anusuk/พื้นโต๊ะ/fast-export/hg2git.py", line 18, in fsencode = lambda s: s.encode(sys.getfilesystemencoding()) UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 13: ordinal not in range(128) /usr/lib/git-core/git-fast-import statistics:

How can I fixed?

frej commented 4 years ago

What is the repo path and does it contain anything that's not ascii?

What does sys.getfilesystemencoding() return if you run it manually in the python interpreter?:

chrisjbillington commented 4 years ago

Looks like your locale is not set correctly.

The filepaths (e.g. /home/anusuk/พื้นโต๊ะ) contain non-ascii characters, but your locale is probably set to ascii.

You could try:

$ LANG=th_TH.UTF-8-8 hg-fast-export.sh -r <local-repo>

But I would think this is a misconfiguration of the system. The locale is set to imply all filepaths are ascii-only, when there are actually utf8 filepaths so this should probably be fixed for the system as a whole.

If the repository itself is indeed ascii-only, then you could try just renaming the พื้นโต๊ะ directory into ascii temporarily (e.g Desktop) whilst running the conversion.

jaideejung007 commented 4 years ago

Looks like your locale is not set correctly.

The filepaths (e.g. /home/anusuk/พื้นโต๊ะ) contain non-ascii characters, but your locale is probably set to ascii.

You could try:

$ LANG=th_TH.UTF-8-8 hg-fast-export.sh -r <local-repo>

But I would think this is a misconfiguration of the system. The locale is set to imply all filepaths are ascii-only, when there are actually utf8 filepaths so this should probably be fixed for the system as a whole.

If the repository itself is indeed ascii-only, then you could try just renaming the พื้นโต๊ะ directory into ascii temporarily (e.g Desktop) whilst running the conversion.

OMG!, it works!!!

I have been changed from พื้นโต๊ะ to Desktop, done!!!

Big thanks!

frej commented 4 years ago

Thanks for the help @chrisjbillington.