Skip to content
meleu-cw edited this page Jan 23, 2024 · 9 revisions

Not following: (error message here)

Reasons include: file not found, no permissions, not included on the command line, not allowing shellcheck to follow files with -x, etc.

Problematic code:

source somefile

Correct code:

In case you have access to the file, e.g. if it is included in your source code repository:

# shellcheck source=somefile
source somefile

In case you do not have access to the file:

# shellcheck source=/dev/null
source somefile

Rationale:

ShellCheck, for whichever reason, is not able to access the source file.

This could be because:

  • you did not include it on the command line,
  • did not use shellcheck -x (or specified external-sources=true in the .shellcheckrc) to allow following other files
  • don't have permissions, or
  • a variety of other problems.

Feel free to ignore the error with a directive.

Exceptions:

ShellCheck is unable to follow dynamic paths, such as source "$somedir/file". For these cases, see SC1090: Can't follow non-constant source. Use a directive to specify location instead. You may be seeing SC1091 because ShellCheck tried to be helpful and strip a leading dynamic path element as described on that page.

If you're fine with it, ignore the message with a directive.

ShellCheck

Each individual ShellCheck warning has its own wiki page like SC1000. Use GitHub Wiki's "Pages" feature guerraart8 to find a specific , or see Checks.

Clone this wiki locally