Skip to content

Build fails when building with the rsa crate #55

@ThomasVille

Description

@ThomasVille

I have a project that uses both this crate and the rsa crate but the build fails with:

$ cargo build
    Updating crates.io index
     Locking 58 packages to latest Rust 1.85.0 compatible versions
   Compiling libc v0.2.174
   Compiling autocfg v1.5.0
   Compiling typenum v1.18.0
   Compiling zerocopy v0.8.26
   Compiling cfg-if v1.0.1
   Compiling libm v0.2.15
   Compiling const-oid v0.9.6
   Compiling version_check v0.9.5
   Compiling serde_json v1.0.140
   Compiling serde v1.0.219
   Compiling base64ct v1.8.0
   Compiling generic-array v0.14.7
   Compiling zeroize v1.8.1
   Compiling num-traits v0.2.19
   Compiling memchr v2.7.5
   Compiling pem-rfc7468 v0.7.0
   Compiling itoa v1.0.15
   Compiling ryu v1.0.20
   Compiling der v0.7.10
   Compiling getrandom v0.2.16
   Compiling deunicode v1.6.2
   Compiling rand_core v0.6.4
   Compiling spin v0.9.8
   Compiling slug v0.1.6
   Compiling lazy_static v1.5.0
   Compiling num-bigint-dig v0.8.4
   Compiling crypto-common v0.1.6
   Compiling digest v0.10.7
   Compiling byteorder v1.5.0
   Compiling smallvec v1.15.1
   Compiling spki v0.7.3
   Compiling signature v2.2.0
   Compiling pkcs8 v0.10.2
   Compiling subtle v2.6.1
   Compiling pkcs1 v0.7.5
   Compiling ppv-lite86 v0.2.21
   Compiling num-integer v0.1.46
   Compiling num-iter v0.1.45
   Compiling rand_chacha v0.3.1
   Compiling rand v0.8.5
   Compiling rsa v0.9.8
   Compiling jmespath v0.3.0
error[E0277]: `(dyn functions::Function + 'static)` cannot be sent between threads safely
   --> /home/thomas/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/jmespath-0.3.0/src/lib.rs:124:1
    |
124 | / lazy_static! {
125 | |     pub static ref DEFAULT_RUNTIME: Runtime = {
126 | |         let mut runtime = Runtime::new();
127 | |         runtime.register_builtin_functions();
128 | |         runtime
129 | |     };
130 | | }
    | |_^ `(dyn functions::Function + 'static)` cannot be sent between threads safely
    |
    = help: the trait `Send` is not implemented for `(dyn functions::Function + 'static)`
    = note: required for `Unique<(dyn functions::Function + 'static)>` to implement `Send`
note: required because it appears within the type `Box<(dyn functions::Function + 'static)>`
   --> /home/thomas/.rustup/toolchains/1.85.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:231:12
    |
231 | pub struct Box<
    |            ^^^
    = note: required because it appears within the type `(std::string::String, Box<(dyn functions::Function + 'static)>)`
    = note: required for `hashbrown::raw::RawTable<(std::string::String, Box<(dyn functions::Function + 'static)>)>` to implement `Send`
note: required because it appears within the type `hashbrown::map::HashMap<std::string::String, Box<(dyn functions::Function + 'static)>, RandomState>`
   --> /rust/deps/hashbrown-0.15.2/src/map.rs:185:12
note: required because it appears within the type `HashMap<std::string::String, Box<(dyn functions::Function + 'static)>>`
   --> /home/thomas/.rustup/toolchains/1.85.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/collections/hash/map.rs:230:12
    |
230 | pub struct HashMap<K, V, S = RandomState> {
    |            ^^^^^^^
note: required because it appears within the type `Runtime`
   --> /home/thomas/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/jmespath-0.3.0/src/runtime.rs:13:12
    |
13  | pub struct Runtime {
    |            ^^^^^^^
    = note: required for `spin::once::Once<Runtime>` to implement `Sync`
note: required because it appears within the type `Lazy<Runtime>`
   --> /home/thomas/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/lazy_static-1.5.0/src/core_lazy.rs:12:12
    |
12  | pub struct Lazy<T: Sync>(Once<T>);
    |            ^^^^
    = note: shared static variables must have a type that implements `Sync`
    = note: this error originates in the macro `__lazy_static_create` which comes from the expansion of the macro `lazy_static` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0277`.
error: could not compile `jmespath` (lib) due to 1 previous error

My Cargo.toml:

[package]
name = "test-jmespath"
version = "0.1.0"
edition = "2024"

[dependencies]
jmespath = "0.3.0"
rsa = "0.9"

My main.rs:

fn main() {
    println!("Hello, world!");
}

@mtdowling Any idea where this issue comes from?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions