anchor icon indicating copy to clipboard operation
anchor copied to clipboard

Anchor build >> thread 'main' panicked at 'Not in workspace.'

Open SkyCandy2 opened this issue 3 years ago • 19 comments

Issue: Cannot get past this 'Not in workspace' issue. Can anyone help?

Terminal command: anchor build

Output: thread 'main' panicked at 'Not in workspace.', cli/src/lib.rs:701:47 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

From cli/src/lib.rs:701:47: 701. let cfg = Config::discover(cfg_override)?.expect("Not in workspace.");

Versions:

  • git version 2.30.1
  • solana-cli 1.9.1
  • anchor-cli 0.20.1
  • Node v16.13.2

SkyCandy2 avatar Jan 23 '22 06:01 SkyCandy2

What is in the directory where you run anchor build?

fanatid avatar Jan 24 '22 10:01 fanatid

had the same thing go into the project folder my error changed but I still have this error Failed to obtain package metadata: cargo metadataexited with an error: error: failed to load manifest for workspace member\?\C:\Users\kamal\Desktop\solana betting\solana-anchor-betting--game\myepicproject\programs*`

Caused by: failed to read \\?\C:\Users\kamal\Desktop\solana betting\solana-anchor-betting--game\myepicproject\programs\*\Cargo.toml

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

KnineVspython avatar Jan 31 '22 01:01 KnineVspython

I'm having the same error as @KnineVspython . I'm on Windows 11.

JacobWarner avatar Mar 03 '22 05:03 JacobWarner

Also getting the "thread 'main' panicked at 'Not in workspace.', cli\src\lib.rs:701:47 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace" error while trying to run anchor build. I am running windows 11

GoodBurger03 avatar Mar 07 '22 18:03 GoodBurger03

@JoshuaBartels0311 can you clarify which anchor version are you use? (otherwise line can be wrong)

fanatid avatar Mar 08 '22 08:03 fanatid

@JoshuaBartels0311 can you clarify which anchor version are you use? (otherwise line can be wrong)

Hello! Yes, I'm using 0.20.0

GoodBurger03 avatar Mar 08 '22 18:03 GoodBurger03

Thanks for the quick reply! Can you also run RUST_BACKTRACE=full anchor build?

fanatid avatar Mar 09 '22 08:03 fanatid

facing the same issue on windows 11 and have WSL(ubuntu installed) , is there any workaround as of now ? "Failed to obtain package metadata:" Anchor version 0.23.0

nabeel99 avatar Apr 06 '22 18:04 nabeel99

I'm having the same error as @KnineVspython . I'm on Windows 11.

https://github.com/KnineVspython/buildspace-projects/blob/main/Solana_And_Web3/en/Section_2/Resources/windows_setup.md check this out man

KnineVspython avatar Apr 26 '22 06:04 KnineVspython

facing same as @SkyCandy2 is facing i am running anchor-cli 0.21.0 in windows 10 please provide solution asap!

suraj1771singh avatar May 02 '22 10:05 suraj1771singh

$ anchor build thread 'main' panicked at 'Not in workspace.', cli\src\lib.rs:750:47 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

Getting this aswell 😞

anchor-cli 0.24.2 solana-cli 1.9.1 cargo 1.60.0

Any solutions or suggestions?

gepthecoder avatar May 05 '22 17:05 gepthecoder

This backtrace is not so useful :( can you paste the backtrace for anchor cli build in debug mode?

fanatid avatar May 05 '22 21:05 fanatid

$ anchor build thread 'main' panicked at 'Not in workspace.', cli\src\lib.rs:750:47 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

Getting this aswell 😞

anchor-cli 0.24.2 solana-cli 1.9.1 cargo 1.60.0

Any solutions or suggestions?

bro u need to pass anchor build from inside the dir u made by anchor init

MukulGari avatar Jun 28 '22 06:06 MukulGari

anchor doesn't like dashes in folder names. underscores are fine.

swolswolomon avatar Aug 21 '22 22:08 swolswolomon

Hi guys, having this issue suddenly as well .... I have referred to previous links as well regarding rustc --version , solana --version as well... I'm not sure why this is happening suddenly as I have not had any issue for the past few months with other projects... Please help! image

bubu59 avatar Aug 28 '22 09:08 bubu59

alright, found a work around with my current issue and that is to init the new project in another current folder that anchor builds fine and turns out it works.... However, this should not be case right?

bubu59 avatar Aug 28 '22 13:08 bubu59

Getting this too!:

thread 'main' panicked at 'Not in workspace.', cli\src\lib.rs:801:15 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

tried running it in its build space but to no avail

troyistroyenzo avatar Feb 21 '23 04:02 troyistroyenzo

just use cargo build instead

cloakd avatar Apr 24 '23 15:04 cloakd

Running into the same error

akp111 avatar Oct 08 '23 10:10 akp111