sqlfluff / vscode-sqlfluff

An extension to use the sqlfluff linter in vscode.
https://marketplace.visualstudio.com/items?itemName=dorzey.vscode-sqlfluff
MIT License
156 stars 33 forks source link

Can't call wrapper script for sqlfluff #49

Open FurcyPin opened 2 years ago

FurcyPin commented 2 years ago

Hi,

First, thanks for the nice plugin!

I'm trying to use a wrapper powershell script that calls sqlfluff instead of calling it directly, but I can't get it to work. (The main reason for using a wrapper is that I would to make sure the user has the same version of sqlfluff installed as the CI/CD pipeline)

As a minimal example I tried this:

  1. I made a simple wrapper script bin\sqlfluff.ps1 that does just this:
sqlfluff $args

(I tried with @args too)

  1. When I call the script from the terminal, it seems to work as expected.
  2. When I set the plugin's "Executable Path" to "sqlfluff", the plugin works fine.
  3. When I set "Executable Path" to "bin\does_not_exists.ps1", I get an "executable not found" error message.
  4. When I set "Executable Path" to "bin\sqlfluff.ps1", I don't get that message, but the plugin does not seem to work. Nothing happen, reformating files has no effect, etc.

I could not find any log or error message, and I have no idea what is wrong with my script (I'm more a bash person than powershell).

Help would be greatly appreciated.

StephenDriffill commented 2 years ago

I have a similar issue: I'm trying to run the docker image of sqlfluff via a bash script rather than my team having to each install python and sqlfluff.

My script:

#!/bin/bash
MSYS_NO_PATHCONV=1 winpty docker run -i --rm -v $(pwd):/sql sqlfluff/sqlfluff $*

When I set my script as the executable path .../sqlfluff.sh nothing happens when I try to run SQLFluff Lint in VSCode and no error.

n1kk0 commented 1 year ago

This syntax works on Linux:

#!/bin/bash

docker run -i --rm -v $(pwd):/sql sqlfluff/sqlfluff $@

and a

"sqlfluff.executablePath": "${workspaceFolder}/sqlfluff.sh"

in the settings.json.