@@ -15,6 +15,14 @@ use vite_str::Str;
1515
1616use crate :: { Error , provider:: ArchiveFormat } ;
1717
18+ #[ cfg( not( target_os = "windows" ) ) ]
19+ fn ensure_tls_provider ( ) {
20+ static INIT : std:: sync:: OnceLock < ( ) > = std:: sync:: OnceLock :: new ( ) ;
21+ INIT . get_or_init ( || {
22+ let _ = rustls:: crypto:: ring:: default_provider ( ) . install_default ( ) ;
23+ } ) ;
24+ }
25+
1826/// Response from a cached fetch operation
1927pub struct CachedFetchResponse {
2028 /// Response body (None if 304 Not Modified)
@@ -37,6 +45,8 @@ pub async fn download_file(
3745 target_path : & AbsolutePath ,
3846 message : & str ,
3947) -> Result < ( ) , Error > {
48+ ensure_tls_provider ( ) ;
49+
4050 tracing:: debug!( "Downloading {url} to {target_path:?}" ) ;
4151
4252 let response = ( || async { reqwest:: get ( url) . await ?. error_for_status ( ) } )
@@ -114,6 +124,8 @@ pub async fn download_file(
114124/// Download text content from a URL with retry logic
115125#[ expect( clippy:: disallowed_types, reason = "HTTP response body is a String" ) ]
116126pub async fn download_text ( url : & str ) -> Result < String , Error > {
127+ ensure_tls_provider ( ) ;
128+
117129 tracing:: debug!( "Downloading text from {url}" ) ;
118130
119131 let content = ( || async { reqwest:: get ( url) . await ?. text ( ) . await } )
@@ -137,6 +149,8 @@ pub async fn fetch_with_cache_headers(
137149 url : & str ,
138150 if_none_match : Option < & str > ,
139151) -> Result < CachedFetchResponse , Error > {
152+ ensure_tls_provider ( ) ;
153+
140154 tracing:: debug!( "Fetching with cache headers from {url}" ) ;
141155
142156 let response = ( || async {
0 commit comments