锚构建错误:不支持获得目标

发布于 2025-02-06 07:59:22 字数 1118 浏览 2 评论 0 原文

问题 当我尝试运行锚固构建时,我会收到以下错误:

error: target is not supported, for more information see: https://docs.rs/getrandom/#unsupported-targets
   --> /Users/mac/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.1.16/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`
   --> /Users/mac/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.1.16/src/lib.rs:292:5
    |
292 |     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` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: build failed

环境:

solana-cli 1.8.13(SRC:42C3FBC1; feat:1006352700)

1.24.3(CE5817A94 2021-05-31)

Rustup -05-18)

锚-CLI 0.24.2

Problem
When i try to run anchor build, i get the following error:

error: target is not supported, for more information see: https://docs.rs/getrandom/#unsupported-targets
   --> /Users/mac/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.1.16/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`
   --> /Users/mac/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.1.16/src/lib.rs:292:5
    |
292 |     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` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: build failed

Environment:

solana-cli 1.8.13 (src:42c3fbc1; feat:1006352700)

rustup 1.24.3 (ce5817a94 2021-05-31)

rustc 1.61.0 (fe5b13d68 2022-05-18)

anchor-cli 0.24.2

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

清欢 2025-02-13 07:59:22

看来您在锚点项目中使用了使用BPF上无法使用的RNG的依赖性。通常,这是由于尝试在您的链程序中包括一个加密软件包的结果。

Looks like you are including a dependency in your anchor project that uses the rng which is not available on bpf. Usually this is a result of trying to include a cryptographic package in your on-chain program.

新雨望断虹 2025-02-13 07:59:22

当我运行锚点init new_program 然后尝试构建它时,我也有类似的问题。我意识到我正在使用较旧版本的锚点,在 AVM使用最新之后,我初始化了一个新项目,并且能够在没有此问题的情况下构建它

I had a similar issue when I ran anchor init new_program and then tried to build it. I realised I was on an older version of anchor, after avm use latest, I initialized a new project and was able to build it without this issue

纸伞微斜 2025-02-13 07:59:22

我遇到了同样的问题,这对我有效,基于此
来自cargo.toml:

getrandom = { version = "0.2", features = ["custom"] }

I faced the same problem and this works for me based on this https://docs.rs/getrandom/0.2.6/getrandom/macro.register_custom_getrandom.html.
from cargo.toml:

getrandom = { version = "0.2", features = ["custom"] }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文