VisualGDB does not update the system-level variables in order to avoid interfering with other tools. Instead, it sets them for just the process it’s launching to configure and build the project.
You can actually dump the configuration and build command lines to batch files, that show all the environment set by VisualGDB, and can be executed manually in order to simplify troubleshooting things. See this page for details.
If changing the variable globally fixed the project, it could have been hardcoded somewhere else (e.g. by editing the Python scripts) and the value set by VisualGDB was conflicting with it. If in doubt, we always suggest doing a clean toolchain installation, using a clean Python environment and a clean ESP-IDF checkouts. We test them before releasing our toolchains, so they should work just fine out-of-the-box.