Git Product home page Git Product logo

Comments (12)

ncalm avatar ncalm commented on July 21, 2024 1

@skaylie I'm brand new to SQLFluff.

The first thing I tried was to install the SQLFluff extension in VS Code. I wasn't using a virtual environment at the time.

This produced the same error - "The sqlfluff executable was not found...etc".

What isn't clear about the extension is that:
You must install python and then install sqlfluff via pip if you want to use the extension.

So, I created a conda environment. Installed python using the Anaconda interface. Then opened an anaconda command prompt in that environment and used pip install sqlfluff:
image

This completed without error. After which, open VS Code from within the environment:
image

After doing this, I no longer have the error and I can use the linter by running sqlfluff lint --dialect mydialect in the VS Code terminal.
image

Linting doesn't appear to happen as I type, so I will play with some settings to see what can be done.

from vscode-sqlfluff.

RobertOstermann avatar RobertOstermann commented on July 21, 2024 1

@ncalm Here are some settings that might be useful to you.

"sqlfluff.dialect": "tsql",
"sqlfluff.linter.delay": 500,
// onType should be default value so not sure why it would not be linting onType for you.
"sqlfluff.linter.run": "onType",

I should update the README to make it clear that sqlfluff must be installed separately.

If linting is not working for you still, you could check the OUTPUT tab (next to terminal) and see the SQLFluff channel, it will tell you which commands are being run.

from vscode-sqlfluff.

cnolanminich avatar cnolanminich commented on July 21, 2024

OK, I got to the bottom of this. My idea was not to add the virtual environment to the PATH, but that was necessary in order for this to work.

I'm a bit confused as to what the sql.linter.executablePath, if the executable also needs to be on the PATH, but I don't currently have an issue. Thanks for creating this extension 🚀

from vscode-sqlfluff.

reubster avatar reubster commented on July 21, 2024

Hi @cnolanminich ,

I'm experiencing this at the moment, and I'm not sure exactly what your fix was. When you say "PATH" do you mean the host os PATH setting? or the virtual env?

from vscode-sqlfluff.

skaylie avatar skaylie commented on July 21, 2024

this is very frustrating as i still get the same error: "The sqlfluff executable was not found. Use the 'Executable Path' setting to configure the location of the executable, or add it to your PATH."

Is there anyone working on a windows machine that's gotten the vscode plugin to work? Can someone please post a CONCRETE EXAMPLE of what the inputs are supposed to look like to input the path to the executable.

from vscode-sqlfluff.

reubster avatar reubster commented on July 21, 2024

@ncalm
My thoughts;

1/ Do you have the vscode settings for sqlfluff in place? I think it needs to know where the .exe is in your virtual environment. I think it's normally;
/.venv/.sqlfluff

Mine also has;

image

2/ If you're using dbt, the other thing I need to do to get it to work was to ensure my profiles.yml was not using any environment variables. Basically dbt needs to work before sqlfluff can work, if you're linting dbt code.

3/ the SQFluff extension will produce logging in Vscode Output tab - SQLFLuff log, or failing that in the Extension Host log.

from vscode-sqlfluff.

ncalm avatar ncalm commented on July 21, 2024

Thanks, @RobertOstermann . It seems I needed to restart VS Code. It's working now, though I'm not fully understanding how to configure the settings. For example, I want to change CP01 to enforce upper case keywords instead of lower case for tsql dialect (which is common practice).

I will read more of the documentation and see what I can find. Thanks to you and other contributors for this great extension.

Thanks, @reubster. I have it working now. I copied the settings JSON from the README and added them to my workplace settings. I've also created the .sqlfluff file and added some items in there.

from vscode-sqlfluff.

RobertOstermann avatar RobertOstermann commented on July 21, 2024

@ncalm This should give an example of setting the upper case keywords rule-configuration. The configuration file might be recognized automatically, but if not you can use the "sqlfluff.config" setting to set the path of the configuration file.

from vscode-sqlfluff.

patrick-wood-vph avatar patrick-wood-vph commented on July 21, 2024

I still seem to be having an issue getting vscode to 'see' the executable. exe seems to be in a standardized location. I have attempted using:
this: C:/Users/pwood/AppData/Roaming/Python/Python311/Scripts/sqlfluff.exe
this: C:\Users\pwood\AppData\Roaming\Python\Python311\Scripts\sqlfluff.exe
this: sqlfluff
and this: sqlfluff.exe
I had assumed one of those paths would have pointed to the exe that is at that path.
Does anyone else know of anything else I might need to do to get this to work?

from vscode-sqlfluff.

RobertOstermann avatar RobertOstermann commented on July 21, 2024

Try running the SQLFluff Debug Extension command and let me know what the results are. That command should tell you where the failure is happening.

If it is indeed at the sqlfluff executable, it should attempt to find the path that you could use.

from vscode-sqlfluff.

patrick-wood-vph avatar patrick-wood-vph commented on July 21, 2024

from vscode-sqlfluff.

RobertOstermann avatar RobertOstermann commented on July 21, 2024

I am not sure if it should/would work in a remote repo. I have only set it up and tried it with a local repository or through WSL.

You could manually set the working directory and see if that works.

from vscode-sqlfluff.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.