Install pio dependencies from platformio.ini file

In order to build my platformio project on Bitbucket pipelines I want to create a docker image on which all the dependencies of my project are installed. In the dockerfile I could write all the install commands separately, but then I always have to update it along with the platformio.ini file when I change a library. Is there a command that installs all the dependencies like it does before building, but without building the project? Something like pio pkg install --from-file platformio.ini?

But if you build the project with pio run all dependencies will be downloaded.

As far as I can see though there is no pio pkg install switch that accepts an input file with a list of dependencies. You could file a feature request at Issues · platformio/platformio-core · GitHub for this.

We use an empty project with our Dockerfile, which builds an empty .c file, with a simple platformio.ini file, which collects our dependencies. Then the Dockerfile can have a pio run in the end, which downloads and installs the requested packages.

platform = ststm32@15.0.0
framework = zephyr
check_tool = cppcheck, clangtidy

board = nucleo_h743zi

Have you tried just base pio pkg install when you changed the working directory to the project? It should install all dependencies.

1 Like

Awesome, this works! Thanks a lot!
However, when I build the project afterwards with pio run -e due, the tool manager installes one last library called platformio/tool-scons@~4.40400.0. Why isn’t this covered by the pio pkg install command?
Further, if I test on the native environment with pio test -e native nothing more is installed, but if I test on the Arduino Due with pio test -e due, the tool manager installs platformio/tools-bossac@~1.0700.0

What are these two libraries needed for? Why don’t they need to be listed in the platformio.ini? Is there an alternative solution to installing them explicitly in the Dockerfile (pio pkt install "platformio/...")?

PlatformIO is based on SCons. So that’s the most fundamental dependency that you will always have.

The uploader tools are installed on-demand and depending on the upload protocol. For example, if you were to set upload_protocol = atmel-ice it would download tool-openocd because that’s what it uses for the upload. I guess you could pio pkg install -g -t "platformio/tools-bossac@~1.0700.0" additionally. Previously there was pio platform install --with-all-packages atmelsam, but that’s deprecated and somewhere’s there is a topic about it.

1 Like

Two more things:

As proposed in the above answers, I run pio pkg install and also manually intall tools-bossac and tool-scons in my Dockerfile. Like this, all platform related dependencies are installed. Then, if I run my docker container in interactive mode (docker run -it <my-container>), and in that container build and test the platformio app, no dependencies need to be installed. However, if I push the docker image to docker hub in order to use it for my CI pipeline on Atlassian, during the automated build (with an own runner running on the same local machine I built the docker image with), suddenly all the Arduino Libraries (e.g. adafruit/Adafruit MCP23017 Arduino Library @ ^2.3.0 or Adafruit BusIO@1.14.1 need to be installed. Why is this different from when I run the container manually? Does pio pkg install not take care of Arduino libraries (specified in the platformio.ini’s lib-deps)? Is there a commad to install these?

Further, another thing that gets installed when using the docker image on Bitbucket Pipelines is throwtheswitch/Unity @ ^2.5.2. But if I also install this in my Dockerfile with pio pkg install --library "throwtheswitch/Unity@^2.5.2", as proposed here, and then run the tests in an interactive docker container, I get the following error message: .pio/libdeps/due/Unity/src/unity_internals.h:11:10: fatal error: unity_config.h: No such file or directory. What’s the issue here?