Common PlatformIO Errors

This page will list some of the most common errors that I have encountered while using PlatformIO IDE. PlatformIO is an extension in Visual Studio Code that will allow you to program your microcontroller board.

Please specify upload_port for environment or use global --upload-port option

I encountered below error while uploading programs from Visual Studio Code to one of my microcontroller board.


Looking for upload port...
Error: Please specify `upload_port` for environment or use global `--upload-port` option.
For some development platforms it can be a USB flash drive (i.e. /media/<user>/<device name>)
*** [upload] Explicit exit, status 1
=============================================== [FAILED] Took 2.03 seconds ===============================================The terminal process "C:\Users\DONSKY\.platformio\penv\Scripts\platformio.exe 'run', '--target', 'upload', '--target', 'monitor', '--environment', 'esp32dev'" terminated with exit code: 1.


I used a different USB Type A cable when uploading my program. It turns out that this cable is only a ‘Charge Only’ cable. Some USB cable data pins are not connected but only the power pins. You would see that your microcontroller board would power up however you would encounter the error above. Make sure that you are using a USB cable that does support data exchange.

PermissionError: [WinError 5] Access is denied

I encountered PermissionError while trying to upload or build a project


> Executing task: C:\Users\DONSKY\.platformio\penv\Scripts\platformio.exe run --target cleanall --environment esp32dev <

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------Removed .pio\build\esp32dev\.sconsign39.dblite
Removed .pio\build\esp32dev\partitions.bin
Removed .pio\build\esp32dev\src\main.cpp.o
PermissionError: [WinError 5] Access is denied: 'D:\\git\\platformio-projects\\esp32-projects\\esp32-send-ldr-data-websockets\\.pio\\libdeps\\esp32dev\\ESP Async WebServer\\.git\\objects\\04\\8cd02469ae0907bde6f6e847c17899131c9593':
  File "C:\users\donsky\.platformio\penv\lib\site-packages\platformio\builder\", line 155:
  File "C:\Users\DONSKY\.platformio\packages\tool-scons\scons-local-4.3.0\SCons\", line 742:
    return self.method(*nargs, **kwargs)
  File "C:\users\donsky\.platformio\penv\lib\site-packages\platformio\builder\tools\", line 64:
  File "C:\users\donsky\.platformio\penv\lib\site-packages\platformio\builder\tools\", line 49:


It turns out that for some unknown reason my library dependencies got corrupted. The quick fix is to delete the .pio file in your project. This should enforce a manual rebuild of your dependencies again.

If you like my post then please consider sharing this. Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *