1

I am trying to build a Rust project and when I try to execute cargo build-bpf --manifest-path=contracts/solana/program/Cargo.toml --bpf-out-dir=dist/solana/program in the terminal I got this error:

Can't get home directory path: environment variable not found

Any ideas about how to solve it?

mikemaccana
  • 110,530
  • 99
  • 389
  • 494
Mircia George
  • 43
  • 1
  • 6

1 Answers1

5

cargo build-bpf requires the HOME environment variable to be set to work. To resolve this, you have a few options:

$Env:Home = "c:\path\to\my\work\dir"

To be honest, I'm not 100% sure that the second option will work.

More information about the specific error you're seeing at the cargo-build-bpf source code: https://github.com/solana-labs/solana/blob/d5dec989b93fc94c9416a60193e52e8b68bd7133/sdk/cargo-build-bpf/src/main.rs#L474

Jon C
  • 7,019
  • 10
  • 17