DoesNotExistError: Could not find path in directory

Sorry for asking about such a very basic question. I’m learning a little bit about IPFS, but I can’t figure out why it’s not working.

I looked at the cp example in the official documentation and tried it with cid in ls, but it kept failing.

const fs = mfs(helia);
    await fs.mkdir("/my-directory");
    let utf8Encode = new TextEncoder();
    let utfDecode = new TextDecoder();
    let test = utf8Encode.encode("abc");
    await fs.writeBytes(test, "/my-directory/foo.txt");
    for await (const buf of fs.cat("/my-directory/foo.txt")) {
      console.info("test", utfDecode.decode(buf));
    }
    const cid = (await fs.stat("/my-directory")).cid.toString();
    for await (const file of fs.ls("/my-directory")) {
      console.log("ls local root test:", file.name); //foo.txt
    }
    for await (const file of fs.ls(cid)) {
      console.log("ls IPFS path root test", file.name); // DoesNotExistError: Could not find path in directory
    }
    for await (const file of fs.ls(`/ipfs/${cid}`)) {
      console.log("ls IPFS path root test", file.name); // DoesNotExistError: Could not find path in directory
    }