Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.

npm run build:program-rust -> macOS and Linux error: could not compile getrandom (lib) #652

@ethanchain

Description

@ethanchain

I tried running the npm run build:program-rust command on both macOs and Linux systems, and the output is shown below:

> [email protected] build:program-rust
> cargo build-bpf --manifest-path=./src/program-rust/Cargo.toml --bpf-out-dir=dist/program
...
error: target is not supported, for more information see: https://docs.rs/getrandom/#unsupported-targets
   --> src/lib.rs:224:9
    |
224 | /         compile_error!("target is not supported, for more information see: \
225 | |                         https://docs.rs/getrandom/#unsupported-targets");
    | |________________________________________________________________________^

   Compiling bv v0.11.1
   Compiling num_cpus v1.13.1
error[E0433]: failed to resolve: use of undeclared crate or module `imp`
   --> src/lib.rs:246:5
    |
246 |     imp::getrandom_inner(dest)
    |     ^^^ use of undeclared crate or module `imp`

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

Environment:

$ rustup show # WSL
Default host: x86_64-unknown-linux-gnu
rustup home:  /home/ethan/.rustup

installed toolchains
--------------------

stable-x86_64-unknown-linux-gnu (default)
1.78.0-x86_64-unknown-linux-gnu
solana

active toolchain
----------------

stable-x86_64-unknown-linux-gnu (default)
rustc 1.81.0 (eeb90cda1 2024-09-04)
$ rustup show # MacBook
Default host: x86_64-apple-darwin
rustup home:  /Users/chansen/.rustup

installed toolchains
--------------------

stable-x86_64-apple-darwin (default)
1.76.0-x86_64-apple-darwin
solana

active toolchain
----------------

stable-x86_64-apple-darwin (default)
rustc 1.79.0 (129f3b996 2024-06-10)
$ solana -vV
solana-cli 1.18.24 (src:7ba2a0e9; feat:3241752014, client:Agave)

This seems to be a bug or version problem of crate getrandom, but the example-helloworld project does not directly depend on getrandom, so it may be a version problem of solana-program, or it may be a problem of getrandom.

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