bash-language-server icon indicating copy to clipboard operation
bash-language-server copied to clipboard

SCRIPTDIR is ignored in subfolders

Open pcastellazzi opened this issue 1 month ago • 0 comments

Code editor

helix

Platform

Ubuntu 24.04.3 LTS

Version

5.6.0

What steps will reproduce the bug?

  1. Create a project with the bash scripts in a subfolder
mkdir -p ~/workspace/src/example/lib
cd ~/workspace
cp /etc/os-release src/example/lib/os-release.ubuntu
cat <<-EOF >src/example/demo.sh
#!/usr/bin/env bash
# shellcheck source=SCRIPTDIR/lib/os-release.ubuntu
source /etc/os-release
EOF
  1. Run an editor with bash-language-server configured. I am using Helix (hx) here.
export BASH_IDE_LOG_LEVEL=debug
hx -v src/example/demo.sh
2025-11-12T01:36:35.888 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Log, message: "04:36:35.884 DEBUG ShellCheck: running \"shellcheck --shell=bash --format=json1 --external-sources --source-path=/home/ubuntu/workspace --source-path=/home/ubuntu/workspace/src/example\"" }
2025-11-12T01:36:35.892 helix_lsp::transport [INFO] bash-language-server <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/ubuntu/workspace/src/example/demo.sh","version":0,"diagnostics":[{"message":"Not following: SCRIPTDIR/lib/os-release.ubuntu: openBinaryFile: does not exist (No such file or directory)","severity":3,"code":"SC1091","source":"shellcheck","range":{"start":{"line":2,"character":7},"end":{"line":2,"character":22}},"codeDescription":{"href":"https://www.shellcheck.net/wiki/SC1091"},"data":{"id":"shellcheck|1091|2:7-2:22"}}]}}

How often does it reproduce? Is there a required condition?

Always.

What is the expected behavior?

ShellCheck should succeed.

What do you see instead?

An error with the following message: Not following: SCRIPTDIR/lib/os-release.ubuntu: openBinaryFile: does not exist (No such file or directory)

Additional information

I can reproduce the issue running:

cat src/example/demo.sh | shellcheck --shell=bash --format=json1 --external-sources --source
-path=/home/ubuntu/workspace --source-path=/home/ubuntu/workspace/src/example -

Which makes me believe it is related to: https://github.com/koalaman/shellcheck/issues/2735

Running shellcheck with the same arguments but passing the file path as argument produces no errors.

pcastellazzi avatar Nov 12 '25 04:11 pcastellazzi