mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-02 10:45:00 +00:00
fix: Use args.encoding when loading .env files
This commit is contained in:
parent
212e22b2b7
commit
07a95deaba
1 changed files with 7 additions and 4 deletions
|
@ -266,7 +266,7 @@ def register_models(git_root, model_settings_fname, io, verbose=False):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def load_dotenv_files(git_root, dotenv_fname):
|
def load_dotenv_files(git_root, dotenv_fname, encoding):
|
||||||
dotenv_files = generate_search_path_list(
|
dotenv_files = generate_search_path_list(
|
||||||
".env",
|
".env",
|
||||||
git_root,
|
git_root,
|
||||||
|
@ -275,8 +275,11 @@ def load_dotenv_files(git_root, dotenv_fname):
|
||||||
loaded = []
|
loaded = []
|
||||||
for fname in dotenv_files:
|
for fname in dotenv_files:
|
||||||
if Path(fname).exists():
|
if Path(fname).exists():
|
||||||
loaded.append(fname)
|
try:
|
||||||
load_dotenv(fname, override=True)
|
load_dotenv(fname, override=True, encoding=encoding, errors='ignore')
|
||||||
|
loaded.append(fname)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error loading {fname}: {e}")
|
||||||
return loaded
|
return loaded
|
||||||
|
|
||||||
|
|
||||||
|
@ -364,7 +367,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
||||||
args, unknown = parser.parse_known_args(argv)
|
args, unknown = parser.parse_known_args(argv)
|
||||||
|
|
||||||
# Load the .env file specified in the arguments
|
# Load the .env file specified in the arguments
|
||||||
loaded_dotenvs = load_dotenv_files(git_root, args.env_file)
|
loaded_dotenvs = load_dotenv_files(git_root, args.env_file, args.encoding)
|
||||||
|
|
||||||
# Parse again to include any arguments that might have been defined in .env
|
# Parse again to include any arguments that might have been defined in .env
|
||||||
args = parser.parse_args(argv)
|
args = parser.parse_args(argv)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue