Should data_dir work per environment? It feels like that would be useful to e.g. load different config files onto each device. I think it was working previously, but now it doesn’t seem to - Ignore unknown configuration option data_dir in section [env] - so perhaps I remember wrong?
data_dir is only settable globally per-project (docs).
Maybe a script can dynamically change env.Replace(PROJECT_DATA_DIR = env.subst("data_dir_$PIOENV"))?
You can specify in platformio.ini different data folders for each build environment
[platformio]
data_dir = ${PROJECT_DIR}/data-${PIOENV}
See Different SPIFFS images for different build environments #4845