Comments (12)
@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:
This completed without error. After which, open VS Code from within the environment:
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.
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.
@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.
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.
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.
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.
@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](https://private-user-images.githubusercontent.com/19515061/253024316-ff87f931-707f-4961-bd1d-78c23a41dcc1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg2NzgyOTgsIm5iZiI6MTcxODY3Nzk5OCwicGF0aCI6Ii8xOTUxNTA2MS8yNTMwMjQzMTYtZmY4N2Y5MzEtNzA3Zi00OTYxLWJkMWQtNzhjMjNhNDFkY2MxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjE4VDAyMzMxOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM4MzdlZDRlMGNmY2E1ZTUxN2VlYzJiNDQ5ZDBhYjYzYTEyODc4NGUzMGVhYTZkMGJhODFhNDRjODcwODM1ZjQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.F1-T8YTXMX00BAJ_HShOhFfY51bUkPaTE2u_0q6-X_E)
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.
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.
@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.
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.
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.
from vscode-sqlfluff.
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)
- Issues with SQLFluff Command Execution and Path Specification HOT 8
- Aligned elements: attempting to set alias_expression HOT 4
- Allow exclude files HOT 1
- Nothing is showing in VS code when we do 'Format Document' HOT 1
- Fixes for LT01 not applied
- Not specifying a SQL Dialect in extension settings leads to confusing error HOT 1
- Environment variables cannot be passed to extension
- VS code SQL editor marks problems but running SQLFluff via terminal doesn't detect problems
- vscode format on save errors due to future deprecation
- `sqlfluff 3.0` release breaks extension `sql` document formatter HOT 5
- OSError: [Errno 6] Device not configured: '/dev/tty' HOT 4
- No documentation or examples for how to override defaults for rules or rule groups HOT 2
- `Format Document` or `SQLFluff: Fix` overwrites file contents with sqlfluff logs HOT 4
- Can't find the sqlfluff.exe file after installation HOT 6
- [Feature] Show rule name in `Problems` tab HOT 2
- Unable to lint non `.sql` files HOT 1
- WSL - Executable not found HOT 2
- Extension doesn't respect warnings from sqlfluff output
- What is the syntax for adding rules? HOT 3
- Command 'Format Document With...' resulted in an error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-sqlfluff.