Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"error: attribute must be applied to a static variable" when compiling #15

Open
jerzybrzoska opened this issue May 17, 2021 · 6 comments

Comments

@jerzybrzoska
Copy link
Contributor

I cloned the repo and run cargo run --release. The process of compilation was not finished due to the following error:

Compiling olm-rs v0.5.0
error: attribute must be applied to a `static` variable
  --> /home/jerzy/.cargo/registry/src/github.com-1ecc6299db9ec823/olm-rs-0.5.0/src/account.rs:41:5
   |
41 |     #[used]
   |     ^^^^^^^

error: attribute must be applied to a `static` variable
  --> /home/jerzy/.cargo/registry/src/github.com-1ecc6299db9ec823/olm-rs-0.5.0/src/inbound_group_session.rs:29:5
   |
29 |     #[used]
   |     ^^^^^^^

error: attribute must be applied to a `static` variable
  --> /home/jerzy/.cargo/registry/src/github.com-1ecc6299db9ec823/olm-rs-0.5.0/src/outbound_group_session.rs:30:5
   |
30 |     #[used]
   |     ^^^^^^^

error: attribute must be applied to a `static` variable
  --> /home/jerzy/.cargo/registry/src/github.com-1ecc6299db9ec823/olm-rs-0.5.0/src/session.rs:34:5
   |
34 |     #[used]
   |     ^^^^^^^

error: aborting due to 4 previous errors

error: could not compile `olm-rs`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed

When I repeated the attempt with --verbose I got the following output from the compiler:

Running `rustc --crate-name olm_rs --edition=2018 /home/jerzy/.cargo/registry/src/github.com-1ecc6299db9ec823/olm-rs-0.5.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no --cfg 'feature="default"' --cfg 'feature="deserialization"' --cfg 'feature="serde"' --cfg 'feature="serde_json"' -C metadata=b157c7051a06e790 -C extra-filename=-b157c7051a06e790 --out-dir /home/jerzy/rumatui/target/release/deps -L dependency=/home/jerzy/rumatui/target/release/deps --extern getrandom=/home/jerzy/rumatui/target/release/deps/libgetrandom-2876f5851e514e72.rmeta --extern olm_sys=/home/jerzy/rumatui/target/release/deps/libolm_sys-83cc2e8b5962926b.rmeta --extern serde=/home/jerzy/rumatui/target/release/deps/libserde-fc9870fbedeeacc2.rmeta --extern serde_json=/home/jerzy/rumatui/target/release/deps/libserde_json-c49d8bd238e2c4e4.rmeta --extern zeroize=/home/jerzy/rumatui/target/release/deps/libzeroize-c8c4f35876105ecb.rmeta --cap-lints allow -L /home/jerzy/rumatui/target/release/build/olm-sys-17d37e7a7ca77f18/out/build`
       Fresh image v0.23.7
error: attribute must be applied to a `static` variable
  --> /home/jerzy/.cargo/registry/src/github.com-1ecc6299db9ec823/olm-rs-0.5.0/src/account.rs:41:5
   |
41 |     #[used]
   |     ^^^^^^^

error: attribute must be applied to a `static` variable
  --> /home/jerzy/.cargo/registry/src/github.com-1ecc6299db9ec823/olm-rs-0.5.0/src/inbound_group_session.rs:29:5
   |
29 |     #[used]
   |     ^^^^^^^

error: attribute must be applied to a `static` variable
  --> /home/jerzy/.cargo/registry/src/github.com-1ecc6299db9ec823/olm-rs-0.5.0/src/outbound_group_session.rs:30:5
   |
30 |     #[used]
   |     ^^^^^^^

error: attribute must be applied to a `static` variable
  --> /home/jerzy/.cargo/registry/src/github.com-1ecc6299db9ec823/olm-rs-0.5.0/src/session.rs:34:5
   |
34 |     #[used]
   |     ^^^^^^^

error: aborting due to 4 previous errors

error: could not compile `olm-rs`

Caused by:
  process didn't exit successfully: `rustc --crate-name olm_rs --edition=2018 /home/jerzy/.cargo/registry/src/github.com-1ecc6299db9ec823/olm-rs-0.5.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no --cfg 'feature="default"' --cfg 'feature="deserialization"' --cfg 'feature="serde"' --cfg 'feature="serde_json"' -C metadata=b157c7051a06e790 -C extra-filename=-b157c7051a06e790 --out-dir /home/jerzy/rumatui/target/release/deps -L dependency=/home/jerzy/rumatui/target/release/deps --extern getrandom=/home/jerzy/rumatui/target/release/deps/libgetrandom-2876f5851e514e72.rmeta --extern olm_sys=/home/jerzy/rumatui/target/release/deps/libolm_sys-83cc2e8b5962926b.rmeta --extern serde=/home/jerzy/rumatui/target/release/deps/libserde-fc9870fbedeeacc2.rmeta --extern serde_json=/home/jerzy/rumatui/target/release/deps/libserde_json-c49d8bd238e2c4e4.rmeta --extern zeroize=/home/jerzy/rumatui/target/release/deps/libzeroize-c8c4f35876105ecb.rmeta --cap-lints allow -L /home/jerzy/rumatui/target/release/build/olm-sys-17d37e7a7ca77f18/out/build` (exit code: 1)
warning: build failed, waiting for other jobs to finish...
error: build failed

@DevinR528
Copy link
Owner

DevinR528 commented May 18, 2021

Ahh crap! It's because of matrix-sdk but I think you can get around by using an older compiler (temporarily, I'll make a PR to update olm-rs in the sdk, or you could if you were interested?). I checked using rust 1.45 and it seems to work.

Thanks for the interest!!

@jerzybrzoska
Copy link
Contributor Author

I'm too much of a newbie in Rust for such an update. I appreciate your help.

@DevinR528
Copy link
Owner

I'll let you know when I get to fix this. In the mean time if you want

rustup install 1.45 minimal
rustup run 1.45 cargo r --release

would be the commands to do what you were doing. I'm not sure if 1.45 is the newest version that would actually work, I feel like I noticed it doing this a few weeks ago so maybe any compiler before 1.53 🤷

@jerzybrzoska
Copy link
Contributor Author

Thanks, I managed to launch the app having compiled it with version 1.45.
P.S. When I run error: invalid toolchain name: 'minimal'
it failed and I got the output:

error: invalid toolchain name: 'minimal'

So I decided to skip the word minimal, like so:
rustup install 1.45 && rustup run 1.45 cargo r --release
and it worked fine.

@DevinR528
Copy link
Owner

I was just reminded that because it was only a patch release running cargo update would have fixed it also 🤦 so that would have been easier, sorry!

@jerzybrzoska
Copy link
Contributor Author

jerzybrzoska commented May 19, 2021

To no avail. I have just run cargo updateand then cargo run --release and I got the same error

"error: attribute must be applied to a static variable"

@DevinR528 DevinR528 reopened this May 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants