@@ -14,7 +14,7 @@ use anyhow::Context;
14
14
use cargo_util:: paths;
15
15
use curl:: easy:: { HttpVersion , List } ;
16
16
use curl:: multi:: { EasyHandle , Multi } ;
17
- use log:: { debug, trace} ;
17
+ use log:: { debug, trace, warn } ;
18
18
use std:: cell:: RefCell ;
19
19
use std:: collections:: { HashMap , HashSet } ;
20
20
use std:: fs:: { self , File } ;
@@ -391,6 +391,25 @@ impl<'cfg> HttpRegistry<'cfg> {
391
391
}
392
392
}
393
393
394
+ // copied from src/cargo/core/package.rs to keep change minimal
395
+ //
396
+ // When dynamically linked against libcurl, we want to ignore some failures
397
+ // when using old versions that don't support certain features.
398
+ macro_rules! try_old_curl {
399
+ ( $e: expr, $msg: expr) => {
400
+ let result = $e;
401
+ if cfg!( target_os = "macos" ) {
402
+ if let Err ( e) = result {
403
+ warn!( "ignoring libcurl {} error: {}" , $msg, e) ;
404
+ }
405
+ } else {
406
+ result. with_context( || {
407
+ anyhow:: format_err!( "failed to enable {}, is curl not built right?" , $msg)
408
+ } ) ?;
409
+ }
410
+ } ;
411
+ }
412
+
394
413
impl < ' cfg > RegistryData for HttpRegistry < ' cfg > {
395
414
fn prepare ( & self ) -> CargoResult < ( ) > {
396
415
Ok ( ( ) )
@@ -553,7 +572,7 @@ impl<'cfg> RegistryData for HttpRegistry<'cfg> {
553
572
554
573
// Enable HTTP/2 if possible.
555
574
if self . multiplexing {
556
- handle. http_version ( HttpVersion :: V2 ) ? ;
575
+ try_old_curl ! ( handle. http_version( HttpVersion :: V2 ) , "HTTP2" ) ;
557
576
} else {
558
577
handle. http_version ( HttpVersion :: V11 ) ?;
559
578
}
0 commit comments