I try 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 on VS Code terminal I got this error: Can't get home directory path: environment variable not found.
Any ideas about how to solve it? I don't know how many details are needed for understanding the problem (I m new with Rust), but I can add more if you ask.
Asked
Active
Viewed 929 times
1
Mircia George
- 13
- 4
1 Answers
4
cargo build-bpf requires the HOME environment variable to be set to work. To resolve this, you have a few options:
- Switch VS Code to use a Bash-supported shell. This will be your easiest option, and then
HOMEwill always be set. More information about how to do that at: How do I use Bash on Windows from the Visual Studio Code integrated terminal? - Set the
HOMEvariable yourself in Powershell, using something like:
$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
- 4,544
- 3
- 11
-
Thanks, second one works – Mircia George Feb 10 '22 at 12:13
-
@MirciaGeorge Then you should accept the answer Jon has given you so others can find it and know it worked – Frank C. Feb 10 '22 at 13:51
-
Try from bash terminal – piash tanjin May 23 '22 at 08:06