Note
We have a big database with Frequently Asked Questions in our Community Forums. Please have a look at it.
Please refer to What is PlatformIO?
.pioenvs
directory¶Please refer to build_dir.
Bash completion support will complete subcommands and parameters. To enable Bash completion for platformio subcommands you need to put into your .bashrc:
eval "$(_PLATFORMIO_COMPLETE=source platformio)"
eval "$(_PLATFORMIO_COMPLETE=source pio)"
To enable zsh
completion please run these commands:
autoload bashcompinit && bashcompinit
eval "$(_PLATFORMIO_COMPLETE=source platformio)"
eval "$(_PLATFORMIO_COMPLETE=source pio)"
Note
For permanent command completion you need to place commands above to
~/.bashrc
or ~/.zshrc
file.
PlatformIO Core is written in Python that is installed by default on the all popular OS except Windows.
Windows Users, please Download the latest Python 2.7.x
and install it. DON’T FORGET to select Add python.exe to Path
feature
on the “Customize” stage, otherwise python
command will not be available.
PlatformIO Core consists of 2 standalone tools in a system:
platformio
or pio
(short alias) - User Guide
piodebuggdb
- alias of platformio debug
If you have PlatformIO IDE already installed, you do not need to install PlatformIO Core separately. Just link these tools with your shell:
In Unix and Unix-like systems, there are multiple ways to achieve this.
You can add PlatformIO executables’ directory to the PATH environmental variable. This method will allow you to execute platformio
commands from any terminal emulator as long as you’re logged in as the user PlatformIO is installed and configured for.
If you use Bash as your default shell, you can do it by editing either ~/.profile
or ~/.bash_profile
and adding the following line:
export PATH=$PATH:~/.platformio/penv/bin
If you use Zsh, you can either edit ~/.zprofile
and add the code above, or for supporting both, Bash and Zsh, you can first edit ~/.profile
and add the code above, then edit ~/.zprofile
and add the following line:
emulate sh -c '. ~/.profile'
After everithing’s done, just restart your session (log out and log back in) and you’re good to go.
If you don’t know the difference between the two, check out this page.
Go to the PlatformIO menu → Settings → PlatformIO IDE, scroll down to the Custom PATH for `platformio` command and enter the following: ~/.platformio/penv/bin
. After you’ve done that, you’ll need to go to the PlatformIO menu → Settings → PlatformIO IDE Terminal, scroll down to the Toggles section and uncheck the Login Shell checkbox. Finally, restart Atom and check out the result.
You can create system-wide symlinks. This method is not recommended if you have multiple users on your computer because the symlinks will be broken for other users and they will get errors while executing PlatformIO commands. If that’s not a problem, open your system terminal app and paste these commands (MAY require administrator access sudo
):
ln -s ~/.platformio/penv/bin/platformio /usr/local/bin/platformio
ln -s ~/.platformio/penv/bin/pio /usr/local/bin/pio
ln -s ~/.platformio/penv/bin/piodebuggdb /usr/local/bin/piodebuggdb
After that, you should be able to run PlatformIO from terminal. No restart is required.
Please read one of these instructions How do I set or change the PATH system variable?
You need to edit system environment variable called Path
and append
C:\Users\{username}\.platformio\penv\Scripts;
path in the beginning of a
list (please replace {username}
with your account name).
Some Cloud & Standalone IDE doesn’t support Arduino files (*.ino
and .pde
) because
they are not valid C/C++ based source files:
Missing includes such as #include <Arduino.h>
Function declarations are omitted.
In this case, code completion and code linting does not work properly or disabled. To avoid this issue you can manually convert your INO files to CPP.
For example, we have the next Demo.ino
file:
void setup () {
someFunction(13);
}
void loop() {
delay(1000);
}
void someFunction(int num) {
}
Let’s convert it to Demo.cpp
:
Add #include <Arduino.h>
at the top of the source file
Declare each custom function (excluding built-in, such as setup
and loop
)
before it will be called.
The final Demo.cpp
:
#include <Arduino.h>
void someFunction(int num);
void setup () {
someFunction(13);
}
void loop() {
delay(1000);
}
void someFunction(int num) {
}
Multiple standalone PlatformIO Core in a system could lead to a different issues. We highly recommend to keep one instance of PIO Core or use built-in PIO Core in PlatformIO IDE:
PlatformIO IDE for Atom - Menu PlatformIO: Settings > PlatformIO IDE > Use built-in PlatformIO Core
Finally, if you have a standalone PlatformIO Core in a system, please open system Terminal (not PlatformIO IDE Terminal) and uninstall obsolete PIO Core:
pip uninstall platformio
# if you used MacOS "brew"
brew uninstall platformio
If you need to have PlatformIO Core globally in a system, please Install PlatformIO Core Shell Commands.
If you use PlatformIO IDE, please check in PlatformIO IDE Settings that “Use built-in PIO Core” is enabled.
If you modify system environment variable PATH
in your Bash/Fish/ZSH
profile, please do not override global PATH
. This line
export PATH="/my/custom/path"
is incorrect. Use export PATH="/my/custom/path":$PATH
instead.
Answered in issue #295.
Answered in issue #252.
Please upgrade SetupTools package:
[sudo] pip uninstall setuptools
[sudo] pip install setuptools
# Then re-install PlatformIO
[sudo] pip uninstall platformio
[sudo] pip install platformio
PlatformIO installs all packages to “home_dir/packages” directory. You MUST HAVE write access for this folder. Please note that PlatformIO does not require “sudo”/administrative privileges.
A quick solution is to remove “home_dir/packages” folder and repeat installation/building/uploading again.
Some antivirus tools forbid programs to create files in background. PlatformIO Package Manager does all work in background: downloads package, unpacks archive in temporary folder and moves final files to “home_dir/packages” folder.
Antivirus tool can block PlatformIO, that is why you see “[Error 5] Access is denied”. Try to disable it for a while or add home_dir directory to exclusion/white list.
As we mentioned in “Solution 2”, antivirus tools can block background file system operations. Other solution is to run PlatformIO Core from a system terminal.
Open System Terminal, on Windows cmd.exe
(not PlatformIO IDE Terminal)
Build project and upload firmware using PlatformIO Core which will download and install all dependent packages:
# Change directory to PlatformIO Project where is located "platformio.ini"
cd path/to/platformio/project
# Force PlatformIO to install all tools
platformio run --target upload
If “platformio” command is not globally available in your environment and you use PlatformIO IDE, please use built-in PlatformIO Core which is located in:
Windows: C:\Users\{username}\.platformio\penv\Scripts\platformio
Please replace {username}
with a real user name
Unix: ~/.platformio/penv/bin/platformio
Note
You can add platformio
and pio
commands to your system environment.
See Install PlatformIO Core Shell Commands.
If none of solutions above does not work for you, you can download and unpack all packages manually to “home_dir/packages”.
Please visit PlatformIO Package Storage and download a package for your platform. A correct package path is “home_dir/packages/{package_name}/package.json”.
Full warning message is “UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal”.
KNOWN ISSUE. Please move your project to a folder which full path does not contain non-ASCII chars.
KNOWN ISSUE. PlatformIO Core currently does not support projects which contain non-ASCII characters (codes) in a full path or depend on the libraries which use non-ASCII characters in their names.
TEMPORARY SOLUTION
Use PlatformIO IDE, it will automatically install PlatformIO Core in a root
of system disk (%DISK%/.platformio
) and avoid an issue when system
User contains non-ASCII characters
Do not use non-ASCII characters in project folder name or its parent folders.
Also, if you want to place PlatformIO Core in own location, see:
Set PLATFORMIO_HOME_DIR
environment variable with own path
Configure custom location per project using home_dir option in Project Configuration File platformio.ini.
Answered in issue #384.