@@ -170,21 +170,28 @@ impl StringKey<'_> {
170
170
pub fn get_value ( & self ) -> String {
171
171
let config = get_config ( ) . unwrap_or_default ( ) ;
172
172
let keys = self . 0 . to_owned ( ) ;
173
+ let default_value = self . 1 . to_owned ( ) ;
174
+
173
175
let mut result;
176
+ let mut first_key = "" ;
174
177
for key in keys {
178
+ if first_key. is_empty ( ) {
179
+ first_key = key;
180
+ }
175
181
if config. contains_key ( key) {
176
182
result = config[ key] . as_str ( ) . unwrap ( ) . to_string ( )
177
183
} else {
178
184
result = env:: var ( get_env_name ( key) ) . unwrap_or_default ( )
179
185
}
180
186
if !result. is_empty ( ) {
181
- if key. eq ( CACHE_PATH_KEY ) {
182
- write_cache_path ( result. clone ( ) ) ;
183
- }
184
- return result;
187
+ // The configuration key for the cache path ("cache-path") is special because
188
+ // the rest of the configuration values depend on this value (since the
189
+ // configuration file is stored in the cache path). Therefore, this value needs
190
+ // to be discovered in the first place and stored globally (on CACHE_PATH)
191
+ return check_cache_path ( key, result, default_value) ;
185
192
}
186
193
}
187
- self . 1 . to_owned ( )
194
+ default_value
188
195
}
189
196
}
190
197
@@ -239,6 +246,22 @@ fn concat(prefix: &str, suffix: &str) -> String {
239
246
version_label
240
247
}
241
248
249
+ fn check_cache_path ( key : & str , value_in_config_or_env : String , default_value : String ) -> String {
250
+ let return_value = if key. eq ( CACHE_PATH_KEY ) {
251
+ if default_value. is_empty ( ) {
252
+ value_in_config_or_env
253
+ } else {
254
+ default_value
255
+ }
256
+ } else {
257
+ value_in_config_or_env
258
+ } ;
259
+ if key. eq ( CACHE_PATH_KEY ) {
260
+ write_cache_path ( return_value. clone ( ) ) ;
261
+ }
262
+ return_value
263
+ }
264
+
242
265
fn write_cache_path ( cache_path : String ) {
243
266
CACHE_PATH . with ( |value| {
244
267
* value. borrow_mut ( ) = cache_path;
0 commit comments