You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After using the library in a cross-platform Python application, I've noticed that it ignores common environment variable overrides that define directory locations on most systems. This includes:
TMPDIR, TEMP, TMP on Unix/Linux/macOS
XDG_CONFIG_HOME, XDG_DATA_HOME, XDG_CACHE_HOME on Linux
Any user-specified overrides for Documents, Downloads, etc.
Example: Temp Directory
importosfromplatformdirsimportPlatformDirsos.environ["TMPDIR"] ="/custom/tmp"dirs=PlatformDirs("MyApp", "MyCompany")
print(dirs.user_cache_dir) # Does NOT reflect TMPDIR override
export XDG_CONFIG_HOME=/tmp/testconfig
python -c "from platformdirs import PlatformDirs; print(PlatformDirs('a', 'b').user_config_dir)"# Still prints ~/.config/a
Expected Behavior
platformdirs should:
Use environment variable overrides as per platform conventions
Match the behavior of tempfile.gettempdir() (for temp dirs)
Match freedesktop spec on Linux (for XDG-based paths)
Current Result
The library hardcodes the path logic and doesn't reflect system/user overrides, making it unsuitable for any situation where the environment is customized — which is very common in packaging, CI/CD, containerized apps, multi-user systems, or advanced user environments.
Suggested Fix / Feature Request
Fall back to current logic only if the environment variable is unset.
Document clearly how the library deals with environment overrides.
Optionally expose a temp_dir property that uses tempfile.gettempdir().
Conclusion
In its current state, platformdirs is nearly useless for real-world use cases where configuration directories, data paths, or temporary locations are customized by the environment. I'd strongly suggest making it respect the standard overrides, or at least make this behavior configurable.
Thanks for considering this!
The text was updated successfully, but these errors were encountered:
In its current state, platformdirs is nearly useless for real-world use cases where configuration directories, data paths, or temporary locations are customized by the environment.
shows that we do respect XDG_CONFIG_HOME, so can't replicate your issue. You might want to attach a reproducible with a Docker image, and more importantly submit PRs where you find feature gaps.
Uh oh!
There was an error while loading. Please reload this page.
Hi, and thanks for
platformdirs
.After using the library in a cross-platform Python application, I've noticed that it ignores common environment variable overrides that define directory locations on most systems. This includes:
TMPDIR
,TEMP
,TMP
on Unix/Linux/macOSXDG_CONFIG_HOME
,XDG_DATA_HOME
,XDG_CACHE_HOME
on LinuxDocuments
,Downloads
, etc.Example: Temp Directory
Compare that with:
Example: XDG Override Ignored
Expected Behavior
platformdirs
should:tempfile.gettempdir()
(for temp dirs)Current Result
The library hardcodes the path logic and doesn't reflect system/user overrides, making it unsuitable for any situation where the environment is customized — which is very common in packaging, CI/CD, containerized apps, multi-user systems, or advanced user environments.
Suggested Fix / Feature Request
temp_dir
property that usestempfile.gettempdir()
.Conclusion
In its current state,
platformdirs
is nearly useless for real-world use cases where configuration directories, data paths, or temporary locations are customized by the environment. I'd strongly suggest making it respect the standard overrides, or at least make this behavior configurable.Thanks for considering this!
The text was updated successfully, but these errors were encountered: