anchor
anchor copied to clipboard
Getting started guide doesn't mention npm installation, which results in Error: No such file or directory (os error 2) when running "anchor init"
Problem:
anchor init anchor-counter --template multiple
has an OS error on Arch Linux.
However, the project is created despite the error. The error occurs every time the command is run.
The solutions at https://solana.stackexchange.com/questions/1648/error-no-such-file-or-directory-os-error-2-error-from-anchor-test don't seem to solve the underlying issue - upon running the anchor init command for multiple files template, a developer shouldn't see an OS error. If it's occurring due to Anchor being unable to generate an IDL from the template, then the template should possibly include the boilerplate necessary to generate a basic IDL.
╭─dev@dev in ~/Code took 4ms
[🔴] × node --version
v22.9.0
╭─dev@dev in ~/Code took 6ms
╰─λ yarn --version
1.22.22
╭─dev@dev in ~/Code took 173ms
╰─λ solana --version
solana-cli 1.18.18 (src:83047136; feat:4215500110, client:SolanaLabs)
╭─dev@dev in ~/Code took 3ms
╰─λ avm --version
avm 0.30.1
╭─dev@dev in ~/Code took 22ms
╰─λ anchor --version
anchor-cli 0.30.1
╭─dev@dev in ~/Code took 3ms
[🔴] × anchor init anchor-counter --template multiple
Error: No such file or directory (os error 2)
╭─dev@dev in ~/Code took 4ms
[🔴] × ls
drwxr-xr-x - dev 25 Sep 19:31 anchor-counter
╭─dev@dev in ~/Code/anchor-counter via v1.81.0 as 🧙 took 8s
[🔍] × tree
.
├── Anchor.toml
├── app
├── Cargo.toml
├── migrations
├── programs
│ └── anchor-counter
│ ├── Cargo.toml
│ ├── src
│ │ ├── constants.rs
│ │ ├── error.rs
│ │ ├── instructions
│ │ │ ├── initialize.rs
│ │ │ └── mod.rs
│ │ ├── lib.rs
│ │ └── state
│ │ └── mod.rs
│ └── Xargo.toml
└── target
└── deploy
└── anchor_counter-keypair.json
10 directories, 11 files
Solution:
Add the boilerplate code to the dummy files that are causing the OS error on anchor init anchor-counter --template multiple