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: 'ascii' codec can't decode byte" #143

Closed
ivankravets opened this issue Mar 27, 2015 · 4 comments

Comments

3 participants
@ivankravets
Copy link
Member

commented Mar 27, 2015

Problem occurs under Windows OS and for environment where configurable encoding is used (non UTF-8 paths).

https://docs.python.org/2/howto/unicode.html#unicode-filenames

import sys
sys.getdefaultencoding()

Try this hook for platformio.util.get_home_dir:

def get_home_dir():
    home_dir = _get_projconf_option_dir(
        "home_dir",
        join(expanduser("~"), ".platformio")
    )

    import sys
    home_dir = home_dir.decode(sys.getfilesystemencoding())

    if not isdir(home_dir):
        os.makedirs(home_dir)

    assert isdir(home_dir)
    return home_dir

How to reproduce? Just create account with "non-UTF-8" chars (Cyrillic is good candidate).

@ivankravets ivankravets added the bug label Mar 27, 2015

@ivankravets ivankravets self-assigned this Mar 27, 2015

@ivankravets ivankravets added this to the 1.4.0 milestone Mar 27, 2015

@ivankravets ivankravets changed the title Fix "UnicodeDecodeError: 'ascii' codec can't decode byte" Fix Windows "UnicodeDecodeError: 'ascii' codec can't decode byte" Mar 27, 2015

@ivankravets ivankravets added the URGENT label Mar 29, 2015

@ivankravets ivankravets assigned valeros and unassigned ivankravets Mar 29, 2015

@ivankravets ivankravets added wontfix and removed URGENT labels Mar 31, 2015

@ivankravets ivankravets assigned ivankravets and unassigned valeros Mar 31, 2015

@ivankravets

This comment has been minimized.

Copy link
Member Author

commented Mar 31, 2015

We can fix this issue within PlatformIO source code, but problem still exists within SCons source code.

Solution

To avoid this issue please re-define PlatformIO home_dir in your project configuration file platformio.ini or set global PLATFORMIO_HOME_DIR system environment variable. PlatformIO uses user's home directory by default, which can contain "non-latin" characters. The easy way is to set home_dir with path, which doesn't contain "non-latin" chars:

platformio.ini

[platformio]
home_dir = C:\.platformio

[env:your_env_here]
....

NOTICE: All PlatformIO based commands should be executed within that project directory, where home_dir is defined.

@ivankravets

This comment has been minimized.

@me21

This comment has been minimized.

Copy link

commented Mar 14, 2017

@ivankravets This error is also triggered by storing project in path containing non-latin characters. The workaround is (obviously) to store projects elsewhere or creating symlink (directory junction) so that PlatformIO does not have to deal with non-latin paths.

PS in my case it was 'utf8' codec, not 'ascii'.

@ivankravets

This comment has been minimized.

Copy link
Member Author

commented Jun 5, 2019

Please open PlatformIO IDE Terminal and type

pio upgrade --dev
pio update

Restart VSCode. Does it work now?

@ivankravets ivankravets reopened this Jun 5, 2019

@ivankravets ivankravets closed this Jun 5, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.