platformio / platformio-vscode-ide

PlatformIO IDE for VSCode: The next generation integrated development environment for IoT
https://marketplace.visualstudio.com/items?itemName=platformio.platformio-ide
Apache License 2.0
1.18k stars 188 forks source link

PIO extension installer shows incorrect/misleading advice when venv is missing #4031

Open tylerl opened 2 months ago

tylerl commented 2 months ago

VSCode: 1.88.1 PIO IDE: v3.3.3

Problem:

Solution:

The output of .../get-platformio-1.2.2.py check python already does show the correct reason why the check failed, as evidenced by the developer tools console log.

Low-effort solution: \ Simply displaying the Reason line of that output in VSCode would let the user know why the check failed, so that information would no longer be masked by the extension and hidden from the user.

High-effort solution: \ Actually detecting the absence of venv at install time by parsing the Reason line or by sending/interpreting an alternate status code from the check python step would allow the installer to handle the absence of the venv package as a separate fault with different resolution steps. This would make the code more complicated, but it would simplify the install process for people with less familiarity with Python.

Error Details and Output:

In VSCode:

PlatformIO: Can not find a working Python 3.6+ Interpreter.
Please install the latest Python3 and restart VSCode

Screenshot 2024-04-20 094325

Developer Tools Console:

[Extension Host] runCommand /bin/python3 (3) ['/home/tylerl/.platformio/.cache/tmp/get-platformio-1.2.2.py', 'check', 'python']0: "/home/tylerl/.platformio/.cache/tmp/get-platformio-1.2.2.py"1: "check"2: "python"length: 3[[Prototype]]: Array(0) {spawnOptions: {…}, _id: '/bin/python3-0.5960698500644768'}
console.ts:137 [Extension Host] /bin/python3 Error: Error: The Python 3.11.8 (/bin/python3) interpreter is not compatible.
Reason: Could not find Python `venv` module

    at /home/tylerl/.vscode-server/extensions/platformio.platformio-ide-3.3.3-linux-x64/node_modules/platformio-node-helpers/dist/index.js:1:5261
    at ChildProcess.i (/home/tylerl/.vscode-server/extensions/platformio.platformio-ide-3.3.3-linux-x64/node_modules/platformio-node-helpers/dist/index.js:1:4559)
        [....]

console.ts:137 [Extension Host] runCommand /bin/python (3) ['/home/tylerl/.platformio/.cache/tmp/get-platformio-1.2.2.py', 'check', 'python'] {spawnOptions: {…}, _id: '/bin/python-0.40082564509572616'}
console.ts:137 [Extension Host] /bin/python Error: Error: The Python 3.11.8 (/bin/python) interpreter is not compatible.
Reason: Could not find Python `venv` module

    at /home/tylerl/.vscode-server/extensions/platformio.platformio-ide-3.3.3-linux-x64/node_modules/platformio-node-helpers/dist/index.js:1:5261
    at ChildProcess.i (/home/tylerl/.vscode-server/extensions/platformio.platformio-ide-3.3.3-linux-x64/node_modules/platformio-node-helpers/dist/index.js:1:4559)
        [....]