I tried some stuff with anchor today but I kept running into issues. I couldnt find a solution for this besides using wsl:

PS E:\Programming\solana\mysolanaapp> anchor build
Failed to obtain package metadata: `cargo metadata` exited with an error: error: failed to load manifest for workspace member `\\?\E:\Programming\solana\mysolanaapp\programs\*`

Caused by:
  failed to read `\\?\E:\Programming\solana\mysolanaapp\programs\*\Cargo.toml`

It happens when I run anchor build or anchor test. Is there any way to fix this or should I just use wsl? I am currently using Windows 10 and the newest versions of anchor, rust and solana cli (just installed them yesterday)

Here is my cargo.toml:

name = "mysolanaapp"
version = "0.1.0"
description = "Created with Anchor"
edition = "2021"

crate-type = ["cdylib", "lib"]
name = "mysolanaapp"

no-entrypoint = []
no-idl = []
no-log-ix-name = []
cpi = ["no-entrypoint"]
default = []

anchor-lang = "^0.24.2"

Everything else in the code is just the default anchor creates. The name of my app is mysolanaapp so no spaces.

  • this is typically due to some crate dependency mismatch or fetch/cache failure. can you edit the post to contain your Cargo.toml for the program thats failing.
    – m_callens
    Jul 14, 2022 at 13:04
  • Do you have a link to your code?
    – Joe C
    Jul 14, 2022 at 15:22
  • I have edited my question with my cargo.toml
    – Pum
    Jul 15, 2022 at 15:12

1 Answer 1


I've run into this error with Anchor a few times. It occurs when something in your repository structure doesn't align with what Anchor or Cargo are looking for.

Anchor is pretty particular about the repository structure for your program, so here's the key naming conventions to look out for:

  • Anchor.toml - Make sure your program's name under [programs.localnet] is represented in snake case (ie. program_name).
  • programs/<program-name> - Make sure the folder your program lives in is named with hyphens (ie. programs/program-name).
  • programs/<program-name>/Cargo.toml - There's two spots in here, the top one under [package] should say name = program-name in hyphen format, and the second one under [lib] should say name = program_name in snake case.
  • programs/<program-name>/lib.rs - Verify the name of your module is the snake case name of your program (ie. pub mod program_name)
  • ^ The ones above are enough to get anchor build working, but you'll also want to change the IDL in the test TS file (tests/*.ts) to match your program name (ie. import { ProgramName } from "../target/types/program_name";)

When you think you've got it all named correctly, delete your target folder before building.

Hope this helps, it trips me up all the time.


I left the above information in case someone does have an issue with naming conventions.

Windows Issues:

I reproduced your issue on Windows since I also typically use WSL2.

I was seeing the following behavior:

Inside the project and VS Code PowerShell terminal:

anchor build

-> Throws (same as OP):

PS C:\Users\<username>\mysolanaapp> anchor build
Failed to obtain package metadata: `cargo metadata` exited with an error: error: failed to load manifest for workspace member `\\?\C:\Users\<username>\mysolanaapp\programs\*`

Inside the project and VS Code PowerShell terminal:

cargo build-bpf

-> Throws:

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

This last one was key. The PowerShell terminal in VS Code can't find the environment variable HOME.


You just need to set this variable in the current VS Code PowerShell terminal:

$Env:HOME = 'C:\Users\<username>'

Or you can choose to set it permanently, by running this in a PowerShell administrator shell:

[Environment]::SetEnvironmentVariable('HOME', 'C:\Users\<username>')

Then close the terminal in VS Code then close VS Code and re-open it (you have to close the terminal first or VS Code will reload it).

After solving this issue I then ran into a privilege error when Cargo tried to download BPF tooling:

A required privilege is not held by the client.

Open Settings > Windows Update > For Developers and enable Developer Mode.

Alternate Solution:

You can also choose to run Bash shells in VS Code instead of PowerShell, where HOME will be set automatically for you.

See [2] in Sources


  • I went through everything you mentioned but from what i can see everything looks right.
    – Pum
    Jul 15, 2022 at 15:13
  • Edited with Windows troubleshooting
    – Joe C
    Jul 15, 2022 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.