-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to suppress "source" errors #738
Comments
There's also the error "Source command could not be analyzed: failed to resolve path" even if the file is sourced conditionally. Example: #!/bin/bash
cd -- "$(dirname -- "${BASH_SOURCE[0]}")" || exit 1
if [[ -f "./conf.sh" ]]; then
# shellcheck disable=SC1091
source "./conf.sh"
fi Error:
|
Thanks for reporting this. Contributions are more than welcome. |
@skovhus Is it possible to hide all Problems reported by the extension? I use shell check extension separately which does the job perfectly. |
Note that the warning “Source command could not be analyzed” isn’t related to shellcheck, it informs the user that jump to definition and documentation across files wouldn’t work. The warning was added to inform the user why these features aren’t working. But I’m considering if we should just disable them. |
Is there a way to config the LSP to disable this "source command" check? |
We are now parsing shellcheck directives in version 1.34 of the vscode extension and the server version 4.8.1. Let me know if this works for you, and if you have further ideas for improving this (or the extension/server in general). Thanks! |
Can you reopen this issue? |
OP? What exactly did you do? Please share more context and the disable directive you used? |
OP is short for "original post". |
Thanks. Can you verify which version of the extension you are using? |
In the following snippet I get warning as shown below. The warning goes away if I change
#shellcheck source=/dev/null
. TestExist || exit
|
Testing v1.35.0, shellcheck directives are parsed, but only if they're just above the line. Directives applying to the entire file are ignored:
For example, the following script generates 3 bashIde warnings and 3 shellcheck warnings: #!/bin/bash
cd -- "$(dirname -- "${BASH_SOURCE[0]}")" || exit 1
if [[ -f "./file.sh" ]]; then
source "./file.sh"
fi
if [[ -f "./file2.sh" ]]; then
source "./file2.sh"
fi
if [[ -f "./file3.sh" ]]; then
source "./file3.sh"
fi
One directive at the top of the file allows to disable all shellcheck warnings, but bashIde still displays its own warnings: #!/bin/bash
# shellcheck disable=SC1091
cd -- "$(dirname -- "${BASH_SOURCE[0]}")" || exit 1
if [[ -f "./file.sh" ]]; then
source "./file.sh"
fi
if [[ -f "./file2.sh" ]]; then
source "./file2.sh"
fi
if [[ -f "./file3.sh" ]]; then
source "./file3.sh"
fi |
FYI I've made the "Source command could not be analyzed" diagnostics message configurable and disabled by default. See #794 – this was released as vscode extension 1.36 and bash-language-server version 4.8.4. I'm contemplating if the message should be on by default, as it should help the user add ShellCheck directives to resolve most issues... |
It works great. Thanks a lot. IMO it could be enabled by default, especially since the error message contains a directive on how to disable it. |
Code editor
VSCode
Platform
Windows
Version
1.33.0
What steps will reproduce the bug?
Create a new repository:
Fill
.env.exmaple
with the following:FOO=""
Fill
test.sh
with the following:Upon doing this, we get two errors in the IDE:
First:
It seems that the language server isn't able to interpret shellcheck comment directives. Is there some other way to suppress the error?
Second:
This error message is confusing, because the
-x
is short for--external-sources
, but it should be already set by the extension.What is the expected behavior?
I expect there to be no error messages in the "Problems" pane of VSCode.
What do you see instead?
I see two errors and it is unclear how to solve / suppress them.
Additional Info
I have
shellcheck
installed, so I presume the extension is automatically picking it up and using it to lint.The text was updated successfully, but these errors were encountered: