Skip to main content
1 of 8
that other guy
  • 122.9k
  • 1
  • 14
  • 13

A generic message like "No such file or directory" only says something about the specific error code that was returned, but nothing about what, where, how or why it happened.

The rest of the error message is vital for filling in the gaps. It's especially important to copy-paste everything exactly as it is, because even tiny changes in punctuation provide important information.

For example, consider these shell script error messages:

 1  : No such file or directory
 2  ./myscript: line 2:  /tmp/myfile: No such file or directory
 3  ./myscript: line 2: '/tmp/myfile': No such file or directory
 4  ./myscript: line 2: *.jpg: No such file or directory
 5  bash: ./myscript: No such file or directory
 6  bash: /myscript: No such file or directory
 7  bash: ./myscript: /bin/bash: bad interpreter: No such file or directory

Here's what you may currently see:

No such file or directory

Here's what a trained eye sees:

  1. There's a leading colon. This script has DOS line terminators.

  2. There are two spaces before the filename. Leading whitespace has snuck into a variable.

  3. There are unexpected quotes around the filename. It's being misquoted.

  4. The filename contains a glob . The pattern doesn't match anything, or is misquoted.

  5. The line starts with bash:, so it's from the shell and not your script. The script may be in a different directory.

  6. There's a missing period. You tried to run . /myscript instead of ./myscript

  7. It mentions a bad interpreter, indicating that the shebang has the wrong path to bash.

So please, always include full, unmodified, unabbreviated output, even if you don't see how it could possibly be relevant.

PS: If you want to hide some information like filenames or hostnames, please don't just edit the output to hide them. Instead, create a new test case with non-sensitive data, make sure it has the same problem, and make a post about that instead.

that other guy
  • 122.9k
  • 1
  • 14
  • 13