@@ -285,7 +285,8 @@ impl CmdAuthLogin {
285
285
let uid = user. id ;
286
286
287
287
// Read / modify / write the credentials file.
288
- let credentials_path = ctx. client_config ( ) . config_dir ( ) . join ( "credentials.toml" ) ;
288
+ let config_dir = ctx. client_config ( ) . config_dir ( ) ;
289
+ let credentials_path = config_dir. join ( "credentials.toml" ) ;
289
290
let mut credentials =
290
291
if let Ok ( contents) = std:: fs:: read_to_string ( credentials_path. clone ( ) ) {
291
292
contents. parse :: < toml_edit:: DocumentMut > ( ) . unwrap ( )
@@ -325,6 +326,12 @@ impl CmdAuthLogin {
325
326
profile. insert ( "token" , toml_edit:: value ( token) ) ;
326
327
profile. insert ( "user" , toml_edit:: value ( uid. to_string ( ) ) ) ;
327
328
329
+ std:: fs:: create_dir_all ( config_dir) . unwrap_or_else ( |_| {
330
+ panic ! (
331
+ "unable to create config directory '{}'" ,
332
+ config_dir. to_string_lossy( )
333
+ )
334
+ } ) ;
328
335
std:: fs:: write ( credentials_path, credentials. to_string ( ) )
329
336
. expect ( "unable to write credentials.toml" ) ;
330
337
@@ -383,7 +390,8 @@ impl CmdAuthLogout {
383
390
return Ok ( ( ) ) ;
384
391
}
385
392
386
- let credentials_path = ctx. client_config ( ) . config_dir ( ) . join ( "credentials.toml" ) ;
393
+ let config_dir = ctx. client_config ( ) . config_dir ( ) ;
394
+ let credentials_path = config_dir. join ( "credentials.toml" ) ;
387
395
388
396
if self . all {
389
397
// Clear the entire file for users who want to reset their known hosts.
@@ -408,6 +416,12 @@ impl CmdAuthLogout {
408
416
let profiles = profiles. as_table_mut ( ) . unwrap ( ) ;
409
417
profiles. remove ( profile_name) ;
410
418
}
419
+ std:: fs:: create_dir_all ( config_dir) . unwrap_or_else ( |_| {
420
+ panic ! (
421
+ "unable to create config directory '{}'" ,
422
+ config_dir. to_string_lossy( )
423
+ )
424
+ } ) ;
411
425
std:: fs:: write ( credentials_path, credentials. to_string ( ) )
412
426
. expect ( "unable to write credentials.toml" ) ;
413
427
println ! (
0 commit comments