Open shawazi opened 1 week ago
I'm not able to reproduce the problem unfortunately. Does it only happen if you use the multiple
template?
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
The Error: No such file or directory (os error 2)
error is a generic file system error, so it's difficult to pinpoint where exactly it's coming from. Searching the web for this error is unlikely to yield good results because of this reason.
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.
The post is from 2 years ago when Anchor had a different way of generating the IDLs. It's also running the anchor test
command, so this problem is unrelated (other than the error itself).
This would be easy to debug if I could reproduce.
Hey, thanks for the response! I realized why it occurred. I didn't have npm installed.
https://www.anchor-lang.com/docs/installation I was following this guide on a fresh system (i believe garuda (arch) with fish, but maybe bash).
I installed node directly, I believe, rather than via nvm. I think nvm may provide node and npm, possibly, and perhaps that's why the anchor-lang installation guide doesn't mention it.
It might be beneficial to add a section in the installation guide for "node" and "npm" (or "nvm" if that has both node and npm), alongside the checks for Rust and Yarn.
It might be beneficial to add a section in the installation guide for "node" and "npm" (or "nvm" if that has both node and npm), alongside the checks for Rust and Yarn.
Possibly, but I'd prefer to handle this error in the CLI itself (provide a good error message) because the installation guide has been getting longer lately, which could be scary for new people.
Since this problem is unrelated to the multiple files template, it would be great if we could either close this issue, or rename it to something that includes npm
.
I see your point, but as a new person following the official documentation, I hit a 30 minute roadblock that hindered additional javascript testing since anchor didn't create the tests directory or package.json, or tell me exactly what went wrong.
It might save a lot of time collectively if the documentation contains the two additional lines to check that the new anchor user has node and npm installed on their system, such as via:
### Node and NPM
Install them both onto your system by following this guide: https://www.freecodecamp.org/news/node-version-manager-nvm-install-guide/
I really think a new person would prefer to have the proper dependencies listed in the getting started guide, rather than playing guessing games with the ambiguous CLI error message. And if the documentation is comprehensive, then there's no mental discrepancy (the documentation for installation doesn't mention node or npm, but the cli error message does? why?)
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.
Solution:
Add the boilerplate code to the dummy files that are causing the OS error on
anchor init anchor-counter --template multiple