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

$20 in sol to whoever can help me solve this getrandom error when i run anchor build #35610

Closed
luckydog6969 opened this issue Jul 24, 2024 · 1 comment

Comments

@luckydog6969
Copy link

disclaimer im a noob so pls bear with me. anyway, when i run cargo build my program compiles successfully but when i run anchor build i get this error output.

error: target is not supported, for more information see: https://docs.rs/getrandom/#unsupported-targets
   --> src/lib.rs:267:9
    |
267 | /         compile_error!("\
268 | |             target is not supported, for more information see: \
269 | |             https://docs.rs/getrandom/#unsupported-targets\
270 | |         ");
    | |__________^

error[E0433]: failed to resolve: use of undeclared crate or module `imp`
   --> src/lib.rs:291:5
    |
291 |     imp::getrandom_inner(dest)
    |     ^^^ use of undeclared crate or module `imp`


For more information about this error, try `rustc --explain E0433`.
error: could not compile `getrandom` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...`.   

according to the documentation of solana (this section corresponds to my error) https://solana.com/docs/programs/lang-rust#depending-on-rand. “Programs are constrained to run deterministically, so random numbers are not available. Sometimes a program may depend on a crate that depends itself on rand even if the program does not use any of the random number functionality. If a program depends on rand, the compilation will fail because there is no get-random support for Solana. “

and it said to add this to the program cargo.toml:
getrandom = { version = "0.1.14", features = ["dummy"] }.
and
getrandom = { version = "0.2.2", features = ["custom"] }.
i tried it and it did not work

givens

  • i dont have getrandom as a direct dependency for my program though i have rand 0.8.5 which doesnt pull in getrandom (but rand 0.7.3 does…which i have as a transitive dependency)
  • my program seems to be pulling in getrandom 0.1.16 and 0.2.15
  • i found that getrandom 0.2.15 is a required dependency of ahash 0.7.8. ahash 0.7.8 is an optional dependency for hashbrown 0.11.2. i tried disabling default features for hashbrown 0.11.2. it did not get rid of ahash 0.7.8

if you solve it drop your sol address and ill send you 20 bucks. appreciate the help!

Copy link
Contributor

This repository is no longer in use. Please re-open this issue in the agave repo: https://github.com/anza-xyz/agave

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

1 participant