How to explicitly include a built-in framework library?

I use lib_ldf_mode = off. It means I need to add the built-in framework libraries in lib_deps or library.json, like this:

{
  "dependencies": {
    "Wire": "*",
    "SPI": "*"
  }
}

Today I’ve tried to use the Preferences built-in ESP32 library, so I did:

{
  "dependencies": {
    "Wire": "*",
    "SPI": "*",
    "Preferences": "*"
  }
}

Unfortunately, the build system picks vshymanskyy/Preferences from PIO’s registry instead of the native library.

What should I do?

I’ve tried to use urls like https://github.com/espressif/arduino-esp32/tree/master/libraries/Preferences or https://github.com/espressif/arduino-esp32.git@libraries/Preferences but it doesn’t seem to work. Also, I work in a team, so I cannot afford pointing to a local absolute path.

If I may ask a counter-question: Why are you using lib_ldf_mode = off? What is the reason for this?

I’m working on a large project where the LDF isn’t suitable. But let’s not lose focus. If you start another topic about the LDF performance issues, I’ll gladly participate : -)

1 Like

I could trick PlatformIO by setting a version number:

{
  "dependencies": {
    "Core": "symlink://../../../AymLibs/Core",
    "Preferences": "3.3.1"
  }
}

Indeed, luckily, vshymanskyy/Preferences doesn’t have a 3.3.1 version, so PlatformIO includes the right library instead.

Nevertheless, I think this issue should be fixed. If someone registers another xxx/Preferences library containing a version 3.3.1, my project will break.

Moreover, what if someone creates a xxx/SPI or xxx/Wire library and register it in the PlatformIO registry? Will it break all the projects that have come to include explicitly the native SPI or Wire libraries over the years? (very common)

Better open a bug in https://github.com/platformio/platformio-core/issues

Done here.