anchor
anchor copied to clipboard
anchor fails windows - I don't want to use WSL. No other solution?
Currently I am trying to run anchor build
but it fails with below message.
G:\Projects\Blockchain\solana\solana-twitter>anchor test
Failed to obtain package metadata: cargo metadata
exited with an error: error: failed to load manifest for workspace member \\?\G:\Projects\Blockchain\solana\solana-twitter\programs\*
Caused by:
failed to read \\?\G:\Projects\Blockchain\solana\solana-twitter\programs\*\Cargo.toml
Caused by: The filename, directory name, or volume label syntax is incorrect. (os error 123)
I have seen the answer to the issue is to use WSL
from anchor fails windows.
But I want any solution that I can utilize without WSL. Please help.
Setting your HOME env variable on windows fixes this issue and also https://github.com/coral-xyz/anchor/issues/1315
I had this issue on windows and set HOME env variable to C:/Users/MyUserName
"anchor build" runs cargo build-bpf which checks for HOME env variable ( see link below ) . On bash shells this is set automatically, but its not set on windows cmd prompt terminal.
https://github.com/solana-labs/solana/blob/d5dec989b93fc94c9416a60193e52e8b68bd7133/sdk/cargo-build-bpf/src/main.rs#L474
open ./Cargo.toml
change "programs/*" to "programs/[your program dic]"
and now you can run "anchor build" on windows.
But "anchor test" still doesn't work, because the solana-test-validator can't run on windows , and seems that solana' dev team don't resolve this problem. solana 4608 So I think you should use linux system or other vm(vitrualbox) to develop
I strongly suggest using WSL2 because previously I am same as you trying to find other solution. In the end I give up. Here's the tutorial installing WSL2. Hope it helps.
https://ubuntu.com/tutorials/install-ubuntu-on-wsl2-on-windows-11-with-gui-support#1-overview
After installing, you can follow this tutorial to setup the Solana environment. https://medium.com/@sncryldrm/setup-solana-development-environment-on-windows-cbed9e42ccef
Hope it helps!