PlatformIO Terminal in VSCode-Plugin: "Command pio not found"

I am doing my first steps with PlatformIO in VScode. The installation run smoothly. I’m able to compile my source code and upload it to the controller without problems. However, when I open a PlatformIO terminal in VScode and type in some pio command, I always get a command 'pio' not found error.

I tried this with a fresh install on a different computer (having the same OS) and there it works as expected.

Executing the command echo $PATH in a PlatformIO terminal prints only my regular standard unix path.
I’m able to run ~/.platformio/penv/bin/pio from a regular unix terminal.

It tried to set the path variable manually as described here without success: Specify Path to PlatformIO in Visual Studio Code. Playing with other options like platformio-ide.updateTerminalPathConfiguration did not help either.

I already uninstalled the PlatformIO plugin and the VScode package and removed the directories ~/.platformIO and ~/.config/Code before re-installing. No success.

Can you help, please?

OS:
Kubuntu 19.10

VScode:
Version: 1.41.1
Commit: 26076a4de974ead31f97692a0d32f90d735645c0
Date: 2019-12-18T15:04:31.999Z
Electron: 6.1.5
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Linux x64 5.3.0-26-generic

PlatformIO IDE Plugin:
1.10.0

Can I just confirm that you opened a PIO Terminal, and weren’t using the one provided on start by VSCode? As that initial terminal usually doesn’t know anything about PIO (probably because it loads before the PIO VSCode extension). First thing I usually do is close it, and then click on the PIO New Terminal icon (last one in the group on the status bar) when I actually want to use PIO, hence I get rid of the non-working terminal, and get a working one when I need it.

2 Likes

That’s what I did now:

  • I opened VScode,
  • closed the initial terminal
  • opened a new one by clicking the right most item in the PIO status bar.

The “command not found” error remains.

I tried opening a new terminal from Quick Access -> Upgrade PlatformIO Core and it still cannot find the “platformio” command.

Have same issue on macos vscode

Hm…

Can you try Help -> Toggle Developer Tools, and have the Console tab open when you try to open the PIO Terminal… normally you won’t get any output to the console when opening the PIO Terminal… hopefully it spits out a error message that gives some idea as to what’s not working properly.

I opened Vscode, opened the Debugger Console and set the log level to verbose. Find the log below. The first part referring to console.ts was already present after startup before I opened the terminal. The violations referring to xterm.js popped up after opening the console. I needed to switch on verbosity to see those violations.

[Extension Host] activating extension

console.ts:137 [Extension Host] starting language server

console.ts:137 [Extension Host] runCommand platformio

1. Array(1)

1. Object

2

console.ts:137 [Extension Host] (node:5695) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.

console.ts:137 [Extension Host] Found PIO Core 4.1.0

console.ts:137 [Extension Host] runCommand platformio

1. Array(8)

1. Object

console.ts:137 [Extension Host] runCommand /home/xxx/.platformio/penv/bin/python3

1. Array(1)

1. Object

console.ts:137 [Extension Host] /home/xxx/.platformio/penv/bin/python3

console.ts:137 [Extension Host] runCommand /home/xxx/.platformio/penv/bin/python3

1. Array(2)

1. Object

/usr/share/code/reso…term/lib/xterm.js:1 [Violation] Added non-passive event listener to a scroll-blocking 'wheel' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952

/usr/share/code/reso…term/lib/xterm.js:1 [Violation] Added non-passive event listener to a scroll-blocking 'wheel' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952

/usr/share/code/reso…term/lib/xterm.js:1 [Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952

/usr/share/code/reso…term/lib/xterm.js:1 [Violation] Added non-passive event listener to a scroll-blocking 'touchmove' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952

/usr/share/code/reso…term/lib/xterm.js:1 [Violation] Added non-passive event listener to a scroll-blocking 'wheel' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952

/usr/share/code/reso…term/lib/xterm.js:1 [Violation] Added non-passive event listener to a scroll-blocking 'wheel' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952

/usr/share/code/reso…term/lib/xterm.js:1 [Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952

/usr/share/code/reso…term/lib/xterm.js:1 [Violation] Added non-passive event listener to a scroll-blocking 'touchmove' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952

Right, so those extra Violations appear to be something specific to VSCode’s terminal, and are not related to PlatformIO… as I was able to get them to pop up occasionally on my Windows install, and PIO is recognised properly here. Caveat: I’m running PIO 4.1.1-b7, so it could be marginally different. VSCode version and extension version are the same though.

The xterm.js related error popped up for me when I clicked the PIO Terminal icon… and not every time, so it’s intermittent as well.

Since you’ve already played with the platformio-ide.updateTerminalPathConfiguration and platformio-ide.updateTerminalPathConfiguration values… and no specific errors are coming up… I’m not sure what’s going on here. I can’t remember how to check if the python virtualenv is working properly, that could be one more thing to check… is there any difference between versions when you run python --version inside the PIO terminal and just at a ‘normal’ system terminal? Other than that, best bet may be to simply delete ~/.platformio whilst VSCode is closed, and let the PlatformIO extension re-install the PlatformIO core - maybe something just went wrong during the install.

Both terminals, inside VScode and in my regular environment show the same python versions: 2.7.17 and 3.7.5. Deleting .platformio and then restarting VScode did not help.

So I guess we are stuck. Never mind. The compile and and upload is still working. Thank you for your help, pfeerick!

Delete all terminals by clicking the Recycle Bin icon on the command palette, and then Ctrl+Shift+P, type “Platformio New Terminal” then you will solve it.

I am also having this pio not found problem. I don’t understand any solution in this thread.

BTW, when I type “python --version” in the window I get “python not found”. How do I install python for platformio in vscode?

Does pio --version work in PlatformIO CLI?

No.

{text to overcome stupid 20 char limit}

Well then you shouldn’t be able to do anything (building, etc) with PlatformIO and it’s really broken. Try a clean re-install.

Builds and uploads work.

My platformio cli terminal is running in wsl ubuntu. Here is a command prompt …

mlap(/mnt/c/Users/mlap/apps/toy-esp32-cam) 

Is this normal?

Have you tried disconnecting from your WSL target in VSCode?

I don’t know how to do that. I don’t know why it is using wsl at all in this project. Where is this specified?

What does it say in the WSL tab about your WSL target if you hover / right on it?

I have the pio terminal open with the ubuntu prompt and that hover says not connected.

Then somehow your terminal settings are wrong. The default shell should launch you into a Powershell, not into a WSL Ubuntu shell.

Try and check your settings in

grafik

for anything weird / non-default. I’m no expert in VSCode configuration though to tell you where there might be something wrong, the default settings just work™ for me.

You may also try and follow these docs to install shell commands globally and then use a new powershell instance, as shown above, to access the command.

The only terminal setting appropriate for windows was integrated vs external terminal. I tried both.

I just opened a powershell terminal and ran C:\Users\mlap\.platformio\penv\Scripts\pio.exe and pio came up. Will doing this give me all the features of the platformio CLI terminal? In other words, why does the platformio CLI terminal exist?