LinuxCommandLibrary

pio-lib

Manage PlatformIO project libraries

TLDR

List installed libraries

$ pio lib list
copy

List built-in libraries based on installed development platforms and their frameworks
$ pio lib builtin
copy

Search for existing libraries
$ pio lib search [keyword]
copy

Show details about a library
$ pio lib show [library]
copy

Install a library
$ pio lib install [library]
copy

Update installed libraries
$ pio lib update
copy

Uninstall a library
$ pio lib uninstall [library]
copy

Show PlatformIO library registry statistics
$ pio lib stats
copy

SYNOPSIS

pio lib [command] [options]

PARAMETERS

install [library_id|name|path|url]
    Installs a specified library or all project dependencies. Can take a library ID, name, path to a local library, or a remote URL (e.g., Git repository).

update [library_id|name]
    Updates installed libraries. If no argument is provided, all installed libraries (global or project) are checked for updates.

search [query]
    Searches the PlatformIO Library Registry for libraries matching the provided query.

list
    Lists currently installed libraries, either globally or within the current project.

show [library_id|name]
    Displays detailed information about a specific library from the PlatformIO Library Registry or an installed version.

builtin
    Manages framework built-in libraries, typically used for listing or updating them.

register
    Registers a new library in the PlatformIO Library Registry, making it discoverable and installable by others.

unpublish [library_id|name]
    Unpublishes a library from the PlatformIO Library Registry (requires ownership).

contribute
    Provides guidance and best practices for contributing libraries to the PlatformIO ecosystem.

-g, --global
    Operate on global libraries instead of project-specific ones. Applicable to various subcommands like install, update, and list.

--project-dir
    Specify the path to the PlatformIO project directory (default is current working directory).

--json-output
    Output results in JSON format, useful for scripting and integration with other tools.

DESCRIPTION

pio lib is a fundamental command-line interface tool within the PlatformIO ecosystem, designed for comprehensive management of external libraries in embedded development projects.

It provides a robust solution for discovering, installing, updating, and removing libraries, streamlining the often complex process of dependency management. Developers can leverage pio lib to search the official PlatformIO Library Registry, install libraries by ID, name, or directly from local paths and remote repositories (like Git URLs).

The command supports both global installations (making libraries available across all projects) and project-specific dependencies, which are typically defined in the platformio.ini configuration file. By automating library dependency resolution, pio lib significantly enhances project reproducibility, maintainability, and collaboration by ensuring that all necessary components are correctly linked during the build process.

CAVEATS

The pio lib command requires the PlatformIO Core CLI to be installed, which in turn depends on Python. Network connectivity is generally necessary for searching, installing, and updating libraries from the PlatformIO Registry or remote sources. Project-specific library dependencies are primarily managed through the platformio.ini configuration file within a PlatformIO project.

LIBRARY DEPENDENCY FINDER (LDF)

pio lib works in conjunction with PlatformIO's intelligent Library Dependency Finder (LDF). The LDF automatically resolves and links library dependencies defined in platformio.ini or detected within source code, ensuring that all required libraries are correctly included during the build process, even when dealing with nested dependencies.

PLATFORMIO LIBRARY REGISTRY

A core feature of pio lib is its seamless integration with the PlatformIO Library Registry. This centralized online repository hosts thousands of community-contributed and official libraries, making it easy for developers to discover, share, and install libraries for their embedded projects with simple command-line calls.

HISTORY

PlatformIO, conceived by Ivan Kravets, began as an open-source project to simplify embedded development across various platforms and frameworks. From its early stages, efficient library management was identified as a critical need, addressing the fragmented and often manual processes prevalent in embedded ecosystems (e.g., Arduino IDE's manual library folder placement). The pio lib command evolved to provide a robust, automated solution for dependency resolution, integrating with the PlatformIO Library Registry and supporting diverse sources like local paths and Git repositories. This significantly enhanced the reusability, maintainability, and version control capabilities for embedded software projects, becoming a cornerstone of the PlatformIO CLI.

SEE ALSO

pio(1), pio run(1), pio project(1), pip(1), npm(1), apt(8)

Copied to clipboard