锚构建错误:不支持获得目标
问题 当我尝试运行锚固构建时,我会收到以下错误:
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看来您在锚点项目中使用了使用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.
当我运行
锚点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, afteravm use latest
, I initialized a new project and was able to build it without this issue我遇到了同样的问题,这对我有效,基于此。
来自cargo.toml:
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: