7

I want to use the sqlfluff extension (extentsion id dorzey.vscode-sqlfluff) in vs code. When I save a sql file I get the following error message in vs code:

"Cannot lint /home/usr/file.sql. The executable was not found. Use the 'Executable Path' setting to configure the location of the executable."

I followed the extensions configuration doecumentation which states:

"The extension expects sqlfluff to be installed and already added to the path. If it is installed but cannot be found, add the path to your preferences as seen below. Find the path by typing which sqlfluff into your terminal."

However, which sqlfluff doesn't print the path in the terminal. Any help is appreciated!

3 Answers 3

8

To specify a custom path to sqlfluff in VS Code,

  1. Open a command prompt and run python -c "import shutil; print(shutil.which('sqlfluff'))" This will print out the path to your local sqlfluff installation.
  2. Copy the path that is printed out. It should end in "sqlfluff.EXE"
  3. In VS Code, click File --> Preferences --> Settings
  4. Find the setting for "Sqlfluff: Executable Path". Paste the path there.
Sign up to request clarification or add additional context in comments.

Comments

4

vscode-sqlfluff does not install sqlfluff itself. You have to install it by yourself.

Follow sqlfluff installation guide

Comments

2

In the most recent version of the extension, there are three parts that need to be properly configured:

  1. Executable Path on OS (Windows in my case):
  • Install Python and Pip, then install sqlfluff using pip:

    $ pip install sqlfluff

  • Verify the package installation by checking the sqlfluff version:

    sqlfluff version

and you should get a response similar to:

2.3.2
  • Check executable location:

    where sqlfluff

  • Add the sqlfluff directory to your path:

    This PC > Properties > Advanced System Settings > Advanced > Environment Variables > System Variables > Path > New > [Insert executable directory here]

  1. Executable Path on VS Code:
  • Assuming the extension is already installed, navigate to File > Preferences > Settings
  • Search for sqlfluff
  • Modify the Sqlfluff: Executable Path setting to point to the sqlfluff executable exposed by where sqlfluff above. e.g.

Sqlfluff: Executable Path

  1. Sqlfluff working directory in User and Workspace on VSCode Settings

Provide the directory in which the executable is found for both.

Sqlfluff working directory

Sqlfluff should now run properly.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.