Skip to content

Added handling for undetermined home directory #30454

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

Merged
merged 2 commits into from
Aug 22, 2025

Conversation

Logan-Pageler
Copy link
Contributor

@Logan-Pageler Logan-Pageler commented Aug 22, 2025

PR summary

If the home directory cannot be created/written to, matplotlib defaults to creating a temporary folder for its caching/config. However, previously, if the home directory could not be determined, a RunTimeError was raised. Now, this pr includes code to handle the RunTimeError from Path.home() so that Matplotlib will default to using a temp directory for its cache. It will also throw a warning to describe the issue.

On Windows the following now leads to a temporary cache directory:

import os
os.environ.pop('HOMEPATH', None)
os.environ.pop('USERPROFILE', None)
import matplotlib

On Linux the following now leads to a temporary cache directory, if the user is not a part of the password database:

import os
os.environ.pop('HOME', None)
import matplotlib

closes #30449

PR checklist

@timhoffm
Copy link
Member

I took the liberty of adding a comment on the cause of the RuntimeError.

This is ready to be (suqash-)merged after CI pass.

@timhoffm timhoffm merged commit 5054100 into matplotlib:main Aug 22, 2025
36 of 37 checks passed
@timhoffm
Copy link
Member

Thanks @Logan-Pageler! Congratulations on your first PR to Matplotlib 🎉 We hope to hear from you again.

@tacaswell tacaswell added this to the v3.11.0 milestone Aug 22, 2025
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.

[Bug]: Config directory location finder doesnt account for the home directory being undetermined.
4 participants