Can't download IDF if core_dir path is too long

I like to have self contained projects, so I changed de core_dir to be inside my project folder.
But because of my folders organization, I have a long absolute path and the IDF don’t download.

When I try to build, I get the error:

Processing esp32dev (platform: espressif32; board: esp32dev; framework: espidf)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Platform Manager: Installing espressif32
Unpacking [################--------------------] 45%
Unpacking…
Platform Manager: Warning! Package Mirror: [Errno 2] No such file or directory: ‘D:\CantDownloadIDFBecauseCoreDirPathIsTooLong\CantDownloadIDFBecauseCoreDirPathIsTooLong\Core\.cache\tmp\pkg-installing-gtouqgmw\examples\espidf-aws-iot\components\esp-aws-iot\aws-iot-device-sdk-embedded-C\samples\linux\shadow_sample_console_echo\aws_iot_config.h’
Platform Manager: Looking for another mirror…
Unpacking [################--------------------] 45%
Unpacking…
Platform Manager: Warning! Package Mirror: [Errno 2] No such file or directory: ‘D:\CantDownloadIDFBecauseCoreDirPathIsTooLong\CantDownloadIDFBecauseCoreDirPathIsTooLong\Core\.cache\tmp\pkg-installing-ma904eic\examples\espidf-aws-iot\components\esp-aws-iot\aws-iot-device-sdk-embedded-C\samples\linux\shadow_sample_console_echo\aws_iot_config.h’
Platform Manager: Looking for another mirror…
Unpacking [################--------------------] 45%
Unpacking…
Platform Manager: Warning! Package Mirror: [Errno 2] No such file or directory: ‘D:\CantDownloadIDFBecauseCoreDirPathIsTooLong\CantDownloadIDFBecauseCoreDirPathIsTooLong\Core\.cache\tmp\pkg-installing-zruf556j\examples\espidf-aws-iot\components\esp-aws-iot\aws-iot-device-sdk-embedded-C\samples\linux\shadow_sample_console_echo\aws_iot_config.h’
Platform Manager: Looking for another mirror…
Error: Could not install package ‘espressif32’ for ‘windows_amd64’ system

The PlatformIO downloads the IDF to “.cache” inside the core_dir and because of the long path, it fails.

This can be fixed if we use the system temp file.
In the “platformio\package\manager\base.py”

ADD:

import tempfile

CHANGE:

    def get_tmp_dir(self):
        if not self._tmp_dir:
          self._tmp_dir = tempfile.gettempdir()
        if not self._tmp_dir:
            self._tmp_dir = self.ensure_dir_exists(
                os.path.join(get_project_cache_dir(), "tmp")
            )
        return self._tmp_dir

Can this or better solution be included in a future version of PlatformIO?

Well at the base level, Windows fails, not PlatformIO. Enabling Win32 Long Paths does not help?

Yap
It solves the problem.

Thanks for the info, I didn’t know that this option existed.