PlatformIO Community

Keep build dir causes FileExistError

When compiling library examples using the --keep-build-dir option for pio ci the existing build dir causes a FileExistError.

OS: Win 10
PlatforIO: 5.1.1

U:\Dev\tool-box\toolbox-remote-cmds>pio ci examples/build_test --lib=. --build-dir ../.build-cache --keep-build-dir --board=teensy40

Error: Traceback (most recent call last):
  File "c:\users\xxx\.platformio\penv\lib\site-packages\platformio\__main__.py", line 109, in main
    cli()  # pylint: disable=no-value-for-parameter
  File "c:\users\xxx\.platformio\penv\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\xxx\.platformio\penv\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "c:\users\xxx\.platformio\penv\lib\site-packages\platformio\commands\__init__.py", line 44, in invoke
    return super(PlatformioCLI, self).invoke(ctx)
  File "c:\users\xxx\.platformio\penv\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\users\xxx\.platformio\penv\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\xxx\.platformio\penv\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "c:\users\xxx\.platformio\penv\lib\site-packages\click\decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "c:\users\xxx\.platformio\penv\lib\site-packages\platformio\commands\ci.py", line 100, in cli
    _copy_contents(join(build_dir, dir_name), contents)
  File "c:\users\xxx\.platformio\penv\lib\site-packages\platformio\commands\ci.py", line 142, in _copy_contents
    copytree(d, join(dst_dir, basename(d)), symlinks=True)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\shutil.py", line 557, in copytree
    return _copytree(entries=entries, src=src, dst=dst, symlinks=symlinks,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\shutil.py", line 458, in _copytree
    os.makedirs(dst, exist_ok=dirs_exist_ok)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\os.py", line 223, in makedirs
    mkdir(name, mode)
FileExistsError: [WinError 183] Cannot create a file when that file already exists: 'U:\\Dev\\tool-box\\.build-cache\\lib\\toolbox-remote-cmds'

If seen this problem being reported as fixed in this topic:

Seems it has snuck in again

Report this as a bug to Issues · platformio/platformio-core · GitHub.

Of course I didn’t think of that when I saw the previous report here :sweat_smile:
Issue can be found here for anyone else encountering this:

1 Like