MohammedFaidey
MohammedFaidey

Reputation: 11

ERROR cargo build sbf Failed to obtain package metadata: `cargo metadata` exited with an error: error: failed to load manifest for workspace member

I tried to build an anchor project

anchor init AnchorProject

cd AnchorProject

anchor build

Then This error appears!

admin@Desktop MINGW64 /d/folder_1/MY_Project/AnchorProject (main)
$ anchor build

Warning: cargo-build-bpf is deprecated. Please, use cargo-build-sbf

cargo-build-bpf child: 
C:\Users\admin\.local\share\solana\install\active_release\bin\cargo-build-sbf.exe --arch bpf

[2022-09-23T17:22:59.130309300Z ERROR cargo_build_sbf] Failed to obtain package metadata: 

`cargo metadata` exited with an error: error: failed to load manifest for workspace member

 `\\?\D:\folder_1\MY_Project\AnchorProject\programs\*`
    
    Caused by:
      failed to read `\\?\D:\folder_1\MY_Project\AnchorProject\programs\*\Cargo.toml`

    Caused by:
      The filename, directory name, or volume label syntax is incorrect. (os error 123)

and I don't understand what the question mark(?) in the above message mean!

note

I have solved the problem of metadata but when I return to build the project there is another message

$anchor build

error: no such subcommand: build-bpf 

Did you mean build-sbf?

also when I tried to write cargo-build-bfs there is another message appears

$cargo-build-bfs

info: uninstalling toolchain 'sbf'
info: toolchain 'sbf' uninstalled
   Compiling getrandom v0.1.16
   Compiling memchr v2.5.0
   Compiling bv v0.11.1
   Compiling quote v1.0.21
   Compiling rustversion v1.0.9
   Compiling blake3 v1.3.1
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` due to 2 previous errors                                
warning: build failed, waiting for other jobs to finish...
                                                                                              ```

Upvotes: 0

Views: 3518

Answers (1)

Frank C.
Frank C.

Reputation: 8088

Solana programs can not include rand as it would result in nondeterministic outcomes. Programs can not do I/O (files, screens, urls, websites, rand, etc., etc.)

See Rust program build restrictions:

Upvotes: 0

Related Questions