astral-sh / ruff-vscode

A Visual Studio Code extension with support for the Ruff linter.
Other
942 stars 45 forks source link

VSCode on remote workstation. Error initializing python #498

Open Paul-Durrant opened 2 weeks ago

Paul-Durrant commented 2 weeks ago

I'm trying to use ruff for linting and formatting (replacing pylint and black) when running Python 3.9 in a virtual environment on a remote workstation using VSCode.

The Ruff logging shows:

2024-06-17 08:53:51.099 [info] Name: Ruff
2024-06-17 08:53:51.099 [info] Module: ruff
2024-06-17 08:53:51.099 [info] Python extension loading
2024-06-17 08:53:51.099 [error] Error initializing python:  [TypeError: Cannot read properties of undefined (reading 'onDidChangeActiveEnvironmentPath')
    at t.initializePython (/users/pauld/.vscode-server/extensions/charliermarsh.ruff-2024.26.0-linux-x64/dist/extension.js:1:51861)
    at async Immediate.<anonymous> (/users/pauld/.vscode-server/extensions/charliermarsh.ruff-2024.26.0-linux-x64/dist/extension.js:1:395588)]
2024-06-17 08:53:51.099 [info] Python extension loaded

I have ruff set up as the python formatter, but VSCode reports: FormattingExtension 'Ruff' is configured as formatter but it cannot format 'Python'-files

Which I suspect is due to the error in the Ruff log.

VSCode version 1.85.2 Python extension version 2022.8.1 Pylance extension version 2022.6.30 Ruff extension version 2024.26.0

VSCode is running on a Mac, Mac OS Sonoma 14.5 The workstation is running Centos 7

relevant settings from VSCode remote settings:

    "[python]": {
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
        "source.fixAll": "explicit",
        "source.organizeImports": "explicit"
        },
        "editor.defaultFormatter": "charliermarsh.ruff"
    },
    "ruff.nativeServer": true,
    "ruff.lint.run": "onSave",
    "ruff.lint.select": [
        "ALL"
    ],
    "ruff.showNotifications": "always",
    "ruff.lint.extendSelect": [
        "ALL"
    ],
    "ruff.lineLength": 88,
MichaReiser commented 2 weeks ago

Hmm. I'm not very familiar with remote development. Can you try if https://github.com/astral-sh/ruff-vscode/issues/178 helps you fix the issue?