3

enter image description here

My tests all run successfully, but at the end of my test execution, I get error Error: No such file or directory (os error 2).

On the anchor discord, I found a thread from February detailing the same issue I had discord link. I recently also added another program to my anchor project, similar to the user who posted on discord, but I only saw this error after upgrading to anchor anchor-cli 0.25.0 and solana solana-cli 1.10.32.

My Anchor.toml has the following. I get the error both in CI and locally, and both environments have ts-mocha and yarn installed.

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

Edit: Looks like it might be a race condition? Removing the parallel flag I now get the below. So I still get the error, but it happens before the success.

Error: No such file or directory (os error 2)
✨  Done in 432.44s.

Edit: Looks like the issue is with multi-programs, or at least the way I have them setup. Removing whirlpool from the directory structure removes the issue. enter image description here

Edit: Fixed!!! I needed this in my dummy whirlpool program

#[program]
pub mod whirlpool {
    use super::*;

    // _val to ensure tx are different so they don't get rejected.
    pub fn initialize(_ctx: Context<Initialize>, _val: u64) -> Result<()> {
        Ok(())
    }
}

#[derive(Accounts)]
pub struct Initialize {}
1

2 Answers 2

4

For multi-program projects, if one of them is a dummy program, you need something like this. The reason is anchor is likely looking for the idl file for this program and it doesn't get generated if there is no program.

#[program]
pub mod whirlpool {
    use super::*;

    // _val to ensure tx are different so they don't get rejected.
    pub fn initialize(_ctx: Context<Initialize>, _val: u64) -> Result<()> {
        Ok(())
    }
}

#[derive(Accounts)]
pub struct Initialize {}
1
  • 2
    Thank you! You can also simplify this by not using any instructions #[program] pub mod my_program {}.
    – acheron
    Nov 17, 2022 at 13:45
0

I got the same error, Error: No such file or directory (os error 2). In my case yarn and node where missing, I forgot to install them.

  • npm install --global yarn
  • sudo apt install nodejs

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.