Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: target/idl/user_g_markets.json doesn't exist. Did you run anchor build? #3505

Open
sardarahmedkhan505 opened this issue Jan 22, 2025 · 1 comment
Labels

Comments

@sardarahmedkhan505
Copy link

I have everything setup and no errors in the code. I doubles check the idl file exist and I am using the
import { UserGMarket } from "../target/types/user_g_market";

and the file exist and when I run cursor on it, giving me the same file, but when I run anchor test --skip-local-validator, its giving me this error
Error: target/idl/user_g_markets.json doesn't exist. Did you run anchor build?
and I run many times
anchor clean and anchor build

But facing the same issue. Here is my cargo.toml file

`[package]
name = "user-g-markets"
version = "0.1.0"
description = "Created with Anchor"
edition = "2021"

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

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

[dependencies]
anchor-lang = "0.29.0"
anchor-spl = "0.29.0"
`

Here is my Anchor.toml file


`[toolchain]

[features]
seeds = false
skip-lint = false

[programs.localnet]
user_g_market = "AnhNCUWgAswftBjPb9So3hXRwzgQk6WdR3ToM14ej9tW"

[registry]
url = "https://api.apr.dev"

[provider]
cluster = "Localnet"
wallet = "/home/ahmed/.config/solana/id.json"

[scripts]
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"
`

and here is the screen shot also

Image

@acheroncrypto
Copy link
Collaborator

It looks like you named your program user-g-market and then renamed it to user-g-markets (or the other way around), but you forgot to change the name in some places. The fix is simple; make program name consistent in all places. For example, in the package section your Cargo.toml, you use user-g-markets:

[package]
name = "user-g-markets"

but in the lib section, you use:

[lib]
name = "user_g_market"

Make sure the names match while keeping the casing consistent e.g. set lib.name to user_g_markets.

The same goes for Anchor.toml:

[programs.localnet]
user_g_market = "AnhNCUWgAswftBjPb9So3hXRwzgQk6WdR3ToM14ej9tW"

Change this to user_g_markets.

And lastly, you didn't share this but, also rename your program module name to user_g_markets:

#[program]
mod user_g_markets {
// ...
}

That's it. However, I'm leaving this open because I think we can improve the error message to include which program names from anchor.workspace is available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants