@@ -303,6 +303,10 @@ error_chain! {
303
303
description( "some requested components are unavailable to download" )
304
304
display( "{}" , component_unavailable_msg( & c, & manifest, & toolchain) )
305
305
}
306
+ ToolchainComponentsMissing ( c: Vec <Component >, manifest: Manifest , toolchain: String ) {
307
+ description( "at least one of the requested components is unavailable to download" )
308
+ display( "{}" , components_missing_msg( & c, & manifest, & toolchain) )
309
+ }
306
310
UnknownMetadataVersion ( v: String ) {
307
311
description( "unknown metadata version" )
308
312
display( "unknown metadata version: '{}'" , v)
@@ -495,6 +499,54 @@ fn component_unavailable_msg(cs: &[Component], manifest: &Manifest, toolchain: &
495
499
String :: from_utf8 ( buf) . unwrap ( )
496
500
}
497
501
502
+ fn components_missing_msg ( cs : & [ Component ] , manifest : & Manifest , toolchain : & str ) -> String {
503
+ assert ! ( !cs. is_empty( ) ) ;
504
+ let mut buf = vec ! [ ] ;
505
+ let suggestion = format ! ( " rustup toolchain add {} --profile minimal" , toolchain) ;
506
+ let nightly_tips = "Sometimes not all components are available in any given nightly. " ;
507
+
508
+ if cs. len ( ) == 1 {
509
+ let _ = writeln ! (
510
+ buf,
511
+ "component {} is unavailable for download for channel '{}'" ,
512
+ & cs[ 0 ] . description( manifest) ,
513
+ toolchain,
514
+ ) ;
515
+
516
+ if toolchain. starts_with ( "nightly" ) {
517
+ let _ = write ! ( buf, "{}" , nightly_tips. to_string( ) ) ;
518
+ }
519
+
520
+ let _ = write ! (
521
+ buf,
522
+ "If you don't need the component, you could try a minimal installation with:\n \n {}" ,
523
+ suggestion
524
+ ) ;
525
+ } else {
526
+ let cs_str = cs
527
+ . iter ( )
528
+ . map ( |c| c. description ( manifest) )
529
+ . collect :: < Vec < _ > > ( )
530
+ . join ( ", " ) ;
531
+ let _ = write ! (
532
+ buf,
533
+ "some components unavailable for download for channel '{}': {}" ,
534
+ toolchain, cs_str
535
+ ) ;
536
+
537
+ if toolchain. starts_with ( "nightly" ) {
538
+ let _ = write ! ( buf, "{}" , nightly_tips. to_string( ) ) ;
539
+ }
540
+ let _ = write ! (
541
+ buf,
542
+ "If you don't need the components, you could try a minimal installation with:\n \n {}" ,
543
+ suggestion
544
+ ) ;
545
+ }
546
+
547
+ String :: from_utf8 ( buf) . unwrap ( )
548
+ }
549
+
498
550
fn install_msg ( bin : & str , toolchain : & str , is_default : bool ) -> String {
499
551
if Toolchain :: is_custom_name ( toolchain) {
500
552
return "\n note: this is a custom toolchain, which cannot use `rustup component add`\n \
0 commit comments