@@ -44,13 +44,16 @@ public static ClientConfig getDefaultInstance() {
4444 private static String getDefaultConfigFilePath () {
4545 String userDir = System .getProperty ("user.home" );
4646 if (userDir == null || userDir .isEmpty ()) {
47- throw new RuntimeException ( "failed getting user home directory" ) ;
47+ return null ;
4848 }
4949 return getDefaultConfigFilePath (userDir , System .getProperty ("os.name" ), System .getenv ());
5050 }
5151
5252 static String getDefaultConfigFilePath (
5353 String userDir , String osName , Map <String , String > environment ) {
54+ if (userDir == null || userDir .isEmpty ()) {
55+ return null ;
56+ }
5457 if (osName != null ) {
5558 String osNameLower = osName .toLowerCase ();
5659 if (osNameLower .contains ("mac" )) {
@@ -60,7 +63,7 @@ static String getDefaultConfigFilePath(
6063 if (osNameLower .contains ("win" )) {
6164 String appData = environment != null ? environment .get ("APPDATA" ) : null ;
6265 if (appData == null || appData .isEmpty ()) {
63- throw new RuntimeException ( "%APPDATA% is not defined" ) ;
66+ return null ;
6467 }
6568 return Paths .get (appData , "temporalio" , "temporal.toml" ).toString ();
6669 }
@@ -122,6 +125,10 @@ public static ClientConfig load(LoadClientConfigOptions options) throws IOExcept
122125 if (file == null || file .isEmpty ()) {
123126 file = getDefaultConfigFilePath ();
124127 }
128+ // No config dir available — return default empty config
129+ if (file == null ) {
130+ return getDefaultInstance ();
131+ }
125132 try {
126133 ClientConfigToml .TomlClientConfig result = reader .readValue (new File (file ));
127134 return new ClientConfig (ClientConfigToml .getClientProfiles (result ));
0 commit comments