Skip to content

Import Project Failure, InvalidLocaleError: Your system's preferred encoding is US-ASCII, but Pants requires UTF-8 #613

@alvinhao

Description

@alvinhao

I'm getting the following error when trying to load a pants project in IntelliJ. I've tried exporting the locales env variables and it didn't help.
IntelliJ 2020.2.4 Ultimate
Pants Support Plugin 1.16.0

pants --target-spec-file=/private/var/folders/7h/rmwfrbf51xxd6lzbx15njjfh0000gn/T/pants_target_specs1199.in --no-quiet export --output-file=/private/var/folders/7h/rmwfrbf51xxd6lzbx15njjfh0000gn/T/pants_depmap_run456.out --formatted
Exit code: 1

Traceback (most recent call last):
File "/Users/alvin.hao/.cache/pants/setup/bootstrap-Darwin-x86_64/1.14.0/bin/pants", line 11, in
sys.exit(main())
File "/Users/alvin.hao/.cache/pants/setup/bootstrap-Darwin-x86_64/1.14.0/lib/python2.7/site-packages/pants/bin/pants_loader.py", line 85, in main
PantsLoader.run()
File "/Users/alvin.hao/.cache/pants/setup/bootstrap-Darwin-x86_64/1.14.0/lib/python2.7/site-packages/pants/bin/pants_loader.py", line 79, in run
cls.ensure_locale()
File "/Users/alvin.hao/.cache/pants/setup/bootstrap-Darwin-x86_64/1.14.0/lib/python2.7/site-packages/pants/bin/pants_loader.py", line 60, in ensure_locale
""".format(encoding, cls.ENCODING_IGNORE_ENV_VAR)
pants.bin.pants_loader.InvalidLocaleError: Your system's preferred encoding is US-ASCII, but Pants requires UTF-8.
Specifically, Python's locale.getpreferredencoding() must resolve to UTF-8.

Fix it by setting the LC_* and LANG environment settings. Example:
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
Or, bypass it by setting the below environment variable.
PANTS_IGNORE_UNRECOGNIZED_ENCODING=1
Note: we cannot guarantee consistent behavior with this bypass enabled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions