Skip to content

Use fallback home directory on Windows #854

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

Conversation

jmschonfeld
Copy link
Contributor

On macOS/Linux, when asking for the home directory of a user that doesn't exist, we fallback to /var/empty - we also have a handful of unit tests in swift-corelibs-foundation that verify this behavior. However, on Windows we currently crash with a fatalError when provided a non-existent user name. swift-corelibs-foundation previously defaulted to /var/empty on Windows too, but that directory doesn't make sense on Windows. Instead, we standardize on a fallback of %SystemDrive%\Users\Public for users that don't exist which is still a valid directory and is close enough to the macOS/Linux semantics despite not having a direct equivalent to /var/empty

@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

@jmschonfeld
Copy link
Contributor Author

@swift-ci please test Windows platform

@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

@jmschonfeld jmschonfeld merged commit ebb00b8 into swiftlang:main Aug 16, 2024
3 checks passed
@jmschonfeld jmschonfeld deleted the windows/default-home-directory branch August 16, 2024 00:28
jmschonfeld added a commit to jmschonfeld/swift-foundation that referenced this pull request Aug 16, 2024
* Use %SystemDrive\Users\Public as fallback home directory on Windows

* Update to ALLUSERSPROFILE

* Fix test failure

* Fix iOS test failure
jmschonfeld added a commit that referenced this pull request Aug 16, 2024
* Use %SystemDrive\Users\Public as fallback home directory on Windows

* Update to ALLUSERSPROFILE

* Fix test failure

* Fix iOS test failure
cthielen pushed a commit to cthielen/swift-foundation that referenced this pull request Nov 8, 2024
* Use %SystemDrive\Users\Public as fallback home directory on Windows

* Update to ALLUSERSPROFILE

* Fix test failure

* Fix iOS test failure
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.

3 participants