{"record":{"id":"80ec27fa82e86be2","repo":"sxyazi/yazi","slug":"failed-to-install-ring-crypto-provider","errorCode":null,"errorMessage":"Failed to install ring crypto provider","messagePattern":"Failed to install ring crypto provider","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-shim/src/rustls.rs","lineNumber":6,"sourceCode":"use anyhow::anyhow;\n\npub(super) fn init() -> anyhow::Result<()> {\n\t::rustls::crypto::ring::default_provider()\n\t\t.install_default()\n\t\t.map_err(|_| anyhow!(\"Failed to install ring crypto provider\"))\n}\n","sourceCodeStart":1,"sourceCodeEnd":8,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-shim/src/rustls.rs#L1-L8","documentation":"yazi-shim initializes rustls by installing the `ring` crate's crypto provider as the process-wide default via `install_default()`. This function returns Err if a default provider was already installed (or installation raced with another thread), so the shim maps that failure to this anyhow error.","triggerScenarios":"`rustls::crypto::ring::default_provider().install_default()` returns Err — most commonly because another part of the program (another shim, aws-lc-rs, or a dependency) already called `install_default()` earlier in the same process.","commonSituations":"Applications linking multiple TLS stacks (e.g. both yazi-shim/rustls+ring and aws-lc-rs based crates); calling this init twice; multithreaded startup where two components race to install a provider.","solutions":["Ensure the shim's init() runs exactly once at startup, before anything else installs a provider","Standardize on one crypto provider (ring OR aws-lc-rs) across all dependencies","Make init idempotent: ignore AlreadyInstalled errors instead of failing","Check dependency features that pull in an alternative rustls crypto provider"],"exampleFix":"// before\n::rustls::crypto::ring::default_provider()\n    .install_default()\n    .map_err(|_| anyhow!(\"Failed to install ring crypto provider\"))\n// after\nlet _ = ::rustls::crypto::ring::default_provider().install_default(); // tolerate already-installed\nOk(())","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match init_result {\n    Err(e) if e.to_string().contains(\"Failed to install ring crypto provider\") => {\n        // A provider is likely already installed — treat as success\n    }\n    other => other,\n}","preventionTips":["Call init once at program startup, before any TLS use","Don't mix ring and aws-lc-rs provider features in one binary","Make provider installation idempotent (ignore AlreadyInstalled)","Audit dependency features that install their own rustls provider"],"tags":["tls","rustls","crypto","initialization"],"backgroundTag":"crypto-provider-already-installed","analyzedSha":"5f901b886b14de1f17460b6e52e9de5d67f8aba9","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}