sublimelsp / LSP-ruff

LSP helper for ruff - an extremely fast Python linter, written in Rust.
https://packagecontrol.io/packages/LSP-ruff
MIT License
38 stars 4 forks source link

Fix LSP-ruff just doesn't work for new installation #62

Closed jfcherng closed 5 months ago

jfcherng commented 5 months ago

Description

LSP-ruff at this moment just doesn't do any diagnosis for people who install LSP-ruff now because for a new user, LSP-ruff will install ruff-lsp==0.0.52 and ruff==0.5.0 but they don't work together.

LSP-ruff: LOG: error: `ruff <path>` has been removed. Use `ruff check <path>` instead.

The ruff <path> usage has been removed in ruff 0.5.0: https://github.com/astral-sh/ruff/releases/tag/0.5.0

Reproduction

You can remove LSP-ruff and reinstall it. Then supposedly the installed ruff will be bumped up to 0.5.0 (and ruff-lsp will hit `ruff <path>` has been removed.).

vgoklani commented 5 months ago

I just did a fresh install of sublime text and installed LSP-ruff (v1.1) from April 19, 2024 - and ruff is not working for me :(

These are the versions of the libraries installed: Name: ruff-lsp - Version: 0.0.54 Name: ruff - Version: 0.5.0

How do I fix this directly? Do I have to wait for the merge? Thanks!

jfcherng commented 5 months ago

Name: ruff-lsp - Version: 0.0.54 Name: ruff - Version: 0.5.0

Your combination should work. I don't know why yours is 0.0.54 though. LSP-ruff pins ruff-lsp==0.0.52 at this moment.

vgoklani commented 5 months ago

Thanks for the reply!

I see this in the console:

LSP: LSP-ruff: Supported execute commands: ['ruff.applyAutofix', 'ruff.applyOrganizeImports', 'ruff.applyFormat']
LSP: LSP-ruff: supported code action kinds: ['quickfix', 'source.fixAll', 'source.organizeImports', 'source.fixAll.ruff', 'source.organizeImports.ruff', 'notebook.source.fixAll', 'notebook.source.organizeImports', 'notebook.source.fixAll.ruff', 'notebook.source.organizeImports.ruff']
LSP-ruff: LOG: Using interpreter executable: /Users/vgoklani/Library/Caches/Sublime Text/Package Storage/LSP-ruff/bin/ruff
LSP-ruff: LOG: Inferred version 0.5.0 for: /Users/vgoklani/Library/Caches/Sublime Text/Package Storage/LSP-ruff/bin/ruff
LSP-ruff: LOG: Found ruff 0.5.0 at /Users/vgoklani/Library/Caches/Sublime Text/Package Storage/LSP-ruff/bin/ruff
LSP-ruff: LOG: Running Ruff with: /Users/vgoklani/Library/Caches/Sublime Text/Package Storage/LSP-ruff/bin/ruff ['--force-exclude', '--no-cache', '--no-fix', '--quiet', '--output-format', 'json', '-', '--config', '/Users/vgoklani/ruff.toml', '--stdin-filename', '/Users/vgoklani/scratch/scratch.py']
LSP-ruff: LOG: error: `ruff <path>` has been removed. Use `ruff check <path>` instead.

I removed the cache folder and also uninstalled and re-installed lsp-ruff, but it keeps install 0.5.0

Is there any way of not having it reference the cache, and forcing it to update to a different version

jfcherng commented 5 months ago

It looks like you don't know how to override a plugin file with your own. You basically use the same filesystem struct but in Packages/. You have to create Packages/LSP-ruff/requirements.txt with the content like what it is in this PR. An issue of doing so is that now ST will always use the override file you've created even if the plugin updates in the future.

vgoklani commented 5 months ago

Thanks for the reply!

To clarify, I should add a requirements.txt file here:

How does this get installed? And how will the LSP-ruff know to use this version going forward?

It's currently loading ruff from the cache:

Thanks!

jfcherng commented 5 months ago

You can delete the whole Package Storage/LSP-ruff and restart ST. LSP-ruff should install ruff-lsp==0.0.54 since then.

jfcherng commented 5 months ago
  • $HOME/Library/Application Support/Sublime Text/Packages/LSP-ruff/requirements.txt

I've never used MacOS. The Packages/ I mean is the directory when you click on "Browse Packages..." image

LDAP commented 5 months ago

63