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

SC1090: ShellCheck can't follow non-constant source. Use a directive to specify location

Open David-Else opened this issue 2 years ago • 2 comments

    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',
    },

David-Else avatar Jul 21 '22 10:07 David-Else

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 "$@"

mamins1376 avatar Aug 19 '22 19:08 mamins1376

Use a .shellcheckrc to control external sources resolution.

jaco-codexorbis avatar Aug 23 '22 07:08 jaco-codexorbis

@mamins1376 @jaco-codexorbis @shabbyrobe any concerns enabling the -x argument to follow includes for everyone?

skovhus avatar Nov 25 '22 11:11 skovhus

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

skovhus avatar Nov 25 '22 12:11 skovhus

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.

mamins1376 avatar Nov 26 '22 17:11 mamins1376

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!

skovhus avatar Dec 14 '22 10:12 skovhus