Skip to content

fix: UnicodeDecodeError when reading UTF-8 config files on Windows CJK locales(non-UTF-8; e.g. Japanese cp932) #3852

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kt-devoss
Copy link

Hi,

This patch fixes a config file decoding issue that occurs on Windows systems with non-UTF-8 locales (e.g., Japanese cp932).

On Windows systems with non-UTF-8 locales (especially CJK: Chinese, Japanese, Korean),
aider fails to read UTF-8-encoded config files (e.g., .aider.conf) if they contain non-ASCII characters.

For example, Japanese Windows uses code page 932 (Shift_JIS),
so Python's open() fails to decode UTF-8 content by default.
This results in a UnicodeDecodeError during startup when loading config files.

This patch explicitly sets encoding="utf-8" via configargparse's internal
_config_file_open_func, ensuring consistent and locale-independent config parsing.

The change is safe for UTF-8 environments and prevents locale-dependent errors
on non-UTF-8 systems (e.g., Japanese Windows).

Thanks!

On Japanese Windows, Python defaults to code page 932 (Shift_JIS),
which causes UnicodeDecodeError when reading UTF-8 config files.

Force UTF-8 via configargparse._config_file_open_func to ensure
locale-independent config loading.
@kt-devoss
Copy link
Author

I’ve created a new issue for this fix:
#3853

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant