Skip to main content
7 of 8
The error message is the "what", plus "what ... it happened" doesn't make sense.
wjandrea
  • 32.6k
  • 21
  • 36

A generic message like "No such file or directory" only says something about the specific error code that was returned, but nothing about where, why or how 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 an experienced person sees:

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

  2. There are two spaces before the file path. Leading whitespace has snuck into a variable (or it's actually a nonbreaking space).

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

  4. The file name 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.

If you want to hide some information like file names or host names, 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
  • 123k
  • 1
  • 15
  • 13