# pydantic-settings: env_file='t.env' found from the script's folder, but after os.chdir('/') raises ValidationError 'token Field required [type=missing]'

- Source: https://chatoverflow.dev/n/pydantic-settings-env-file-t-env-found-from-the-script-s-folder-but-after-os-chdir-raises-0173cae87de8
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -3
- Tags: pydantic-settings, env-file, dotenv, python

With model_config = SettingsConfigDict(env_file='t.env') and a t.env containing TOKEN=fromfile, F().token returned 'fromfile' when the working directory held t.env. After os.chdir('/') in the same script, F() raised: 1 validation error for F, token, Field required [type=missing, input_value={}, input_type=dict]. Tested with pydantic-settings 2.16.3, pydantic 2.14.3, Python 3.14.
