From 42cefa5d3552eeeb0badf0c44de1e9f1df93a1d5 Mon Sep 17 00:00:00 2001 From: kekland Date: Sat, 25 Apr 2026 10:15:27 +0500 Subject: [PATCH 1/2] fix: no HOME in cmd.exe Co-authored-by: Copilot --- lib/src/locate_ndk.dart | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/src/locate_ndk.dart b/lib/src/locate_ndk.dart index 8fd0895..2c8abae 100644 --- a/lib/src/locate_ndk.dart +++ b/lib/src/locate_ndk.dart @@ -378,10 +378,18 @@ class NDKLocator { /// Expands a path template with environment variables and glob patterns. static List expandPath(String pathTemplate) { - final path = pathTemplate.replaceAll( - '\$HOME', - Platform.environment['HOME']!, - ); + final homeDirectory = + Platform.isWindows + ? Platform.environment['USERPROFILE'] + : Platform.environment['HOME']; + + if (homeDirectory == null) { + throw Exception( + 'Failed to find home directory. Please ensure that the HOME environment variable is set. On Windows, the USERPROFILE environment variable should be set instead.', + ); + } + + final path = pathTemplate.replaceAll('\$HOME', homeDirectory); final glob = Glob(path); final matches = glob.listSync(); return matches; From fe66d6099436bfc3c447492fc2ad7a48e672f695 Mon Sep 17 00:00:00 2001 From: kekland Date: Sat, 25 Apr 2026 10:24:33 +0500 Subject: [PATCH 2/2] fix: replace backslashes with forward slashes in USERPROFILE --- lib/src/locate_ndk.dart | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/src/locate_ndk.dart b/lib/src/locate_ndk.dart index 2c8abae..ef594d8 100644 --- a/lib/src/locate_ndk.dart +++ b/lib/src/locate_ndk.dart @@ -378,10 +378,9 @@ class NDKLocator { /// Expands a path template with environment variables and glob patterns. static List expandPath(String pathTemplate) { - final homeDirectory = - Platform.isWindows - ? Platform.environment['USERPROFILE'] - : Platform.environment['HOME']; + final homeDirectory = Platform.isWindows + ? Platform.environment['USERPROFILE']?.replaceAll('\\', '/') + : Platform.environment['HOME']; if (homeDirectory == null) { throw Exception(