ashish10alex / vscode-dataform-tools

Dataform tools - a vscode extension
https://marketplace.visualstudio.com/items?itemName=ashishalex.dataform-lsp-vscode
MIT License
9 stars 2 forks source link

New repo and encountering issue in sqlfluff [WSL Ubuntu] #24

Closed msnillo closed 6 days ago

msnillo commented 1 week ago

Hi @ashish10alex,

Creating an issue again because I cannot use the formatting of sqlfluff via extension. Here are the steps I took:

  1. Opened the folder in the root of dataform repository

  2. Ran dataform install & dataform init-creds bigquery - both were successful

  3. Encountered the error of sqlfluff not found

    image
  4. Also tried the reloading the VSCode window

  5. Encountered the error of sqlfluff cli not found in path

    image
  6. But you can see in the image below that I have sqlfluff in .vscode-dataform-tools

    image

Would like to know if I did anything wrong?

Thanks!

ashish10alex commented 6 days ago

Hi @msnillo , Thanks for the detailed issue. The reason it shows the error is due to sqlfluff cli not being available in path. The latest version of the extension (v0.0.50) now just uses sqlfluff cli as its dependancy. You can resolve this issue by doing the following

  1. Open wsl terminal, ensure that you are NOT in a python virtual environment and run pip uninstall sqlfluff followed by pip install sqlfluff
  2. Running (1) would show you where the pip installs the sqfluff cli. It will show you a warning that the installed binary is perhaps not in your system path. See screenshot attached.
  3. You can resolve this by adding the path to your system path by adding the highlighted path to your ~/.zshrc or ~/.bashrc file by running the following

    #modify the below using the path you see 
    export PATH=$PATH:/home/aalex/.local/bin
  4. After doing the (3) either restart the terminal or source your ~/.zshrc or ~/.bashrc for the path addition to take effect
  5. Now you can confirm that sqlfluff is installed as expected by running sqlfluff --version. Following which formatting should work as expected

Please do let me know if the above solves your issue

sqlfluff_path_issue

msnillo commented 6 days ago

Awesome, thank you! The issue has been fixed. I'll also close this issue.