Can't modify lib_deps in extra script

Hello,

In my platformio, i have a root env where I have defined lib_deps for all my sub env and I want to add some libraries in few sub-env.

I have made an extrascript

Import("env")
libs=env.GetProjectOption("lib_deps")
libs.append("crankyoldgit/IRremoteESP8266@2.7.9")
print(libs)

env.Replace(lib_deps=libs)

but it doesn’t work
libs contains all the librairies but during build IRremoteESP8266 isn’t used.
I think the line "env.Replace(lib_deps=libs) is wrong !

Check out

So you could try

Import("env")
platform = env.PioPlatform()
libs=env.GetProjectOption("lib_deps")
libs.append("crankyoldgit/IRremoteESP8266@2.7.9")
print(libs)
env_section = "env:" + env["PIOENV"]
platform.config.set(env_section, "lib_deps", libs)

Thank you Max,
It works very well