[nativeaot] set $HOME
and $TMPDIR
#9889
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context: https://github.com/dotnet/runtime/blob/d09a42b9149e14a37c8ef8363cdb7e17bb922c37/src/libraries/System.Private.CoreLib/src/System/IO/Path.Unix.cs#L83
System.IO.Path.GetTempPath()
doesn't work under NativeAOT as seen by the test failure:On Unix-like systems, the BCL just reads
$TMPDIR
and falls back to/tmp/
if it doesn't exist.$TMPDIR
is not set by default in Android applications.To fix this, we can set
$TMPDIR
tocontext.getCacheDir()
just as we do in Mono:android/src/java-runtime/java/mono/android/MonoPackageManager.java
Lines 53 to 54 in 04cd6f4
android/src/native/mono/monodroid/monodroid-glue.cc
Lines 1444 to 1445 in 04cd6f4
I think we can simply read these values in Java at startup, and call
Os.setenv()
to set them. There does not seem to be a need to pass these paths into managed code.The
Android.RuntimeTests.InputStreamInvokerTest.InputStreamTest()
test now passes with these changes.I fixed
$HOME
as well, as it will be used by other APIs in the BCL.