sqlfluff / vscode-sqlfluff

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

Can't find the sqlfluff.exe file after installation #133

Open BartWinterCoolblue opened 4 months ago

BartWinterCoolblue commented 4 months ago

Hi! I just installed the sqfluff extension in VScode. Unfortunately, I got the message that the sqlfluff executable was not found. 'which sqlfluff' is not working and I also don't see the file in any of my repositories. Does anyone how to solve this issue?

perlego-maares commented 4 months ago

Hi @BartWinterCoolblue, the vscode extension does not install sqlFluff on your local, it just use it. Please do have a look at the readme file

quote:

Configuration

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.
aaronclong commented 3 months ago

What if sqlfluff is installed by poetry or in other virtual env in python? Is there a way to have it detect that?

perlego-maares commented 3 months ago

@aaronclong independently of the how is installed, either local or v. env, when performing cmd such as “which sqlfluff” once installed should recover the path, if still is not found add it to the shell paths:

echo $PATH

include the path in which sqlfluff is included into $PATH

while also add the executable path in your setting.json from your profile used in vscode.

"sqlfluff.executablePath": "/Library/Frameworks/Python.framework/Versions/X.XX/bin/sqlfluff”

Not quite follow the issue, maybe adding console error details will help.

aaronclong commented 3 months ago

@perlego-maares so their isn't one install of sqlfluff but installed in virtual environment that will change depending on the project/repo.

In addition putting the hardcode coded path there makes the config completely unusable for teams/multiple contributors.

If you aren't familiar with Python virtual environments, this article should cover it "Python Virtual Environments Explained with Examples".

The suggestion to simply add it to the PATH on each Vscode load is rather burdensome and manual.

aaronclong commented 3 months ago

It would be nice if the config could specify a dependencyManager and directory. The extension could load this.

settings.json

"sqlfluff.dependencyManager": "poetry",
"sqlfluff.projectRoot": "${workspace}/path"

Then the linter provider could spawn a child process and get exec from there.

With poetry, you can dynamically fetch the path from this poetry run which sqlfluff.

image
const { exec } = require('child_process');
return new Promise((resolve, reject) => {
  exec('poetry run which sqlfluff', (error, stdout, stderr) => {
     if (error || stderr) {
        reject(error || stderr);
        return;
     }

    resolve(stdout)
  });
});
aaronclong commented 2 months ago

@perlego-maares what are your thoughts on the above?^