bash-language-server
bash-language-server copied to clipboard
SC1090: ShellCheck can't follow non-constant source. Use a directive to specify location
source ~/dotfiles/neovim/.config/nvim/plugged/fzf/shell/key-bindings.bash
Causes SC1090
When calling shellcheck from the command line you can use -x
:
-x --external-sources Allow 'source' outside of FILES
But this is not enabled in bash-language-server
. Could it be made available as an option when starting the server, or maybe as the default? (not sure of the downsides of having it as a default)
Neovim has the following default settings for bash-language-server
: https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/bashls.lua
As an example, something like this could be used:
settings = {
external_sources = 'on',
},
simple workaround for now - create a script named shellcheck
which adds that for you, and add it to $PATH
(either global or specific to bash-language-server invoker):
#!/bin/sh
exec /usr/bin/shellcheck -x "$@"
Use a .shellcheckrc
to control external sources resolution.
@mamins1376 @jaco-codexorbis @shabbyrobe any concerns enabling the -x
argument to follow includes for everyone?
Correction, we actually already use the -x / --external-sources
option. I assume that the issue here could be that the --source-path
path is always set to current working directory.
https://github.com/bash-lsp/bash-language-server/blob/main/server/src/linter.ts#L87
any concerns enabling the
-x
argument to follow includes for everyone?
I haven't had any problems since. There might be potential security or performance reasons for not doing so, but I don't think they are serious and frequent enough to require explicit enabling of script sourcing. I personally prefer an opt-out approach for such cases.
I believe this should be fixed now in [email protected] and in the latest vscode extension 1.23.0.
Can you test it out and let me know if it works for you? Thanks!