Error when removing files!

when I remove files using the command "ipfs files rm ",there is always error.


Please help me. Thanks.

If you do ipfs files ls / can you see the foo file or bar file? Might be that you just haven’t created those files yet.

I have already created them.And I can find them .

hello Lewis114

try ipfs files ls <you_hash> : https://ipfs.io/docs/commands/#ipfs-file-ls
and ipfs you cannot rm a file add into ipfs networks you can unpin : https://ipfs.io/docs/commands/#ipfs-pin-rm

i suppose you haven’t add your directory in ipfs ipfs add -r my_test/

Thank you again!
I have created the files and added them as the quick-start teaches. The add command also returned hashes. Why always say “File does not exist”? Another Question

I did not delete the files when clicking the cross.

when you click on croos i think you unpin this hash. a think you lost you can retrive you file if you use hash and no filename.

Reagards


Is there mistake with my actions?

try ipfs files rm -r foo ?


There is no merkledag. I don’t know why.

yes it’s weird. you path seems not present on your dht :frowning:

ok could you try that

  1. create foo directories

mkdir -p ~/foo/bar/
echo 'test' > ~/foo/bar/test.txt

  1. add recursively this directory
    ipfs add -r ~/foo/
    important keep in your mind foo hash

  2. cp your test
    ipfs files cp /ipfs/hash_foo_directory /examples

  3. ls with ipfs
    ipfs files ls -l /examples/bar/

  4. rm
    ipfs files rm /examples/bar/test.txt

works fine for you ?

Your ipfs add -r foo adds the contents of the foo directory to IPFS, but does not make it available under /foo in the IPFS files structure.

It took me a little while to get my head around :slight_smile:

When you add content to IPFS, you associate that content with a hash. Using ipfs files, you can make a hash available via a named path within IPFS.

So, if you want to make your foo directory available under /foo, you would need to:

ipfs files cp /ipfs/<foo hash> /foo

That tells IPFS to make a named path at /foo pointing to <foo hash>.

At that point, you can add contents to that path – the hash it points to will change. You can also remove that path, but the contents will remain in IPFS unless you unpin the hash and garbage collect.

Here’s an example:

$ mkdir myfoo
$ echo "hello" > myfoo/welcome.txt
$ ipfs add -r myfoo/
added QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN myfoo/welcome.txt
added QmV5dQgh2mcuCu9URB7fcbuY5JJhvXnLGX1SSmTG6LvT6D myfoo
$ ipfs files cp /ipfs/QmV5dQgh2mcuCu9URB7fcbuY5JJhvXnLGX1SSmTG6LvT6D /foo
$ ipfs files ls /foo
welcome.txt
$ ipfs files read /foo/welcome.txt
hello
$ ipfs files stat /foo
QmV5dQgh2mcuCu9URB7fcbuY5JJhvXnLGX1SSmTG6LvT6D
Size: 0
CumulativeSize: 71
ChildBlocks: 1
Type: directory
$ echo "this is a new file that changes the hash" | ipfs add
added QmZD2PGH9tYAPvBN4stRcLekvtNUQWoS5WnyqCmsjnBBoF QmZD2PGH9tYAPvBN4stRcLekvtNUQWoS5WnyqCmsjnBBoF
$ ipfs files cp /ipfs/QmZD2PGH9tYAPvBN4stRcLekvtNUQWoS5WnyqCmsjnBBoF /foo/new.txt
$ ipfs files ls /foo
new.txt
welcome.txt
$ ipfs files stat /foo
QmTAxwYEKstRRTxGMxpYsEehtmYo8cLFH5i2zvj152sc2A
Size: 0
CumulativeSize: 169
ChildBlocks: 2
Type: directory
$ ipfs files rm -r /foo
$ ipfs ls QmTAxwYEKstRRTxGMxpYsEehtmYo8cLFH5i2zvj152sc2A
QmZD2PGH9tYAPvBN4stRcLekvtNUQWoS5WnyqCmsjnBBoF 49 new.txt
QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN 14 welcome.txt
2 Likes