Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Summary This PR does two things: 1. As `ruff.path` is an array, we need to check each entry and only proceed with the first valid path ([`ruff-lsp` reference](https://github.com/astral-sh/ruff-lsp/blob/c51c77c269c3f13be2534d118b81e1c3b9bbfaff/ruff_lsp/server.py#L1773-L1784)) 2. Consider `useBundled` import strategy fixes: #507 ## Test Plan ### 1 One valid path: ```json { "ruff.nativeServer": true, "ruff.importStrategy": "useBundled", "ruff.path": ["/Users/dhruv/work/astral/ruff/target/debug/ruff"] } ``` Logs: ``` 2024-07-02 15:43:01.550 [info] Using 'path' setting: /Users/dhruv/work/astral/ruff/target/debug/ruff 2024-07-02 15:43:01.550 [info] Server run command: /Users/dhruv/work/astral/ruff/target/debug/ruff server --preview 2024-07-02 15:43:01.550 [info] Server: Start requested. ``` ### 2 Multiple valid paths: ```json { "ruff.nativeServer": true, "ruff.importStrategy": "useBundled", "ruff.path": [ "/Users/dhruv/.local/bin/ruff", "/Users/dhruv/work/astral/ruff/target/debug/ruff" ] } ``` Logs: ``` 2024-07-02 15:44:12.698 [info] Using 'path' setting: /Users/dhruv/.local/bin/ruff 2024-07-02 15:44:12.698 [info] Server run command: /Users/dhruv/.local/bin/ruff server --preview 2024-07-02 15:44:12.698 [info] Server: Start requested. ``` ### 3 First is an invalid path, second is a valid path: ```json { "ruff.nativeServer": true, "ruff.importStrategy": "useBundled", "ruff.path": [ "/Users/dhruv/random/ruff", "/Users/dhruv/work/astral/ruff/target/debug/ruff" ] } ``` Logs: ``` 2024-07-02 15:44:47.816 [info] Using 'path' setting: /Users/dhruv/work/astral/ruff/target/debug/ruff 2024-07-02 15:44:47.816 [info] Server run command: /Users/dhruv/work/astral/ruff/target/debug/ruff server --preview 2024-07-02 15:44:47.816 [info] Server: Start requested. ``` ### 4 All invalid paths, should fallback to using bundled executable: ```json { "ruff.nativeServer": true, "ruff.importStrategy": "useBundled", "ruff.path": [ "/Users/dhruv/random/ruff", "/Users/dhruv/another/random/ruff" ] } ``` Logs: ``` 2024-07-02 15:59:44.215 [info] Could not find executable in 'path': /Users/dhruv/random/ruff, /Users/dhruv/another/random/ruff 2024-07-02 15:59:44.215 [info] Using bundled executable: /Users/dhruv/work/astral/ruff-vscode/bundled/libs/bin/ruff 2024-07-02 15:59:44.215 [info] Server run command: /Users/dhruv/work/astral/ruff-vscode/bundled/libs/bin/ruff server --preview 2024-07-02 15:59:44.215 [info] Server: Start requested. ``` ### 5 No paths given, should fallback to using bundled executable: ```json { "ruff.nativeServer": true, "ruff.importStrategy": "useBundled", "ruff.path": [] } ``` Logs: ``` 2024-07-02 15:45:34.349 [info] Using bundled executable: /Users/dhruv/work/astral/ruff-vscode/bundled/libs/bin/ruff 2024-07-02 15:45:34.349 [info] Server run command: /Users/dhruv/work/astral/ruff-vscode/bundled/libs/bin/ruff server --preview 2024-07-02 15:45:34.349 [info] Server: Start requested. ``` ### 6 No paths, not using bundled executable, let the Python script decide on which executable to use: ```json { "ruff.nativeServer": true, "ruff.path": [] } ``` Logs: ``` 2024-07-02 15:50:13.326 [info] Server run command: /Users/dhruv/work/astral/ruff-vscode/.venv/bin/python /Users/dhruv/work/astral/ruff-vscode/bundled/tool/ruff_server.py server --preview 2024-07-02 15:50:13.326 [info] Server: Start requested. ```
- Loading branch information