What could cause touch to fail with this error message?
touch: cannot touch `foo': No such file or directory
Note that an error due to incorrect permissions looks different:
touch: cannot touch `foo': Permission denied
Following sequence causes this error message:
$ mkdir foo $ cd foo
In another terminal:
$ rm -r foo
In the previous terminal:
$ touch x touch: cannot touch `x': No such file or directory
Of course, other events that also result in invalidating the current working directory (CWD) of a process that tries to create a file there also yield this error message.
For me it was trying to write to a symlink that was pointing to a file that was no longer there:
$ ln -s ~/doomed/file ~/mysymlink $ rm ~/doomed/file $ touch ~/mysymlink $ touch: cannot touch `mysymlink': No such file or directory
Another (simpler) way to trigger the message:
$ mkdir foo $ touch foo/bar/baz.txt touch: cannot touch 'foo/bar/baz.txt': No such file or directory
Basically trying to create a file in a non-existent folder.