ESPHome compliation OSError: [Errno 5] Input/output error: 'install-arduino-ide.sh'

I am having issues compiling ESPHome for some of my devices which previously compiled fine. I am trying to update my devices from the ESPHome dashboard and am getting the following error:

ESPHome 2023.5.4
INFO Reading configuration /config/esphome/gosund-up11-plug-1.yaml...
INFO Detected timezone 'Europe/London'
INFO Generating C++ source...
INFO Core config or version changed, cleaning build files...
INFO Deleting /data/gosund-up11-plug-1/.piolibdeps
Traceback (most recent call last):
  File "/usr/local/bin/esphome", line 33, in <module>
    sys.exit(load_entry_point('esphome', 'console_scripts', 'esphome')())
  File "/esphome/esphome/__main__.py", line 967, in main
    return run_esphome(sys.argv)
  File "/esphome/esphome/__main__.py", line 954, in run_esphome
    rc = POST_CONFIG_ACTIONS[args.command](args, config)
  File "/esphome/esphome/__main__.py", line 397, in command_run
    exit_code = write_cpp(config)
  File "/esphome/esphome/__main__.py", line 179, in write_cpp
    return write_cpp_file()
  File "/esphome/esphome/__main__.py", line 194, in write_cpp_file
    writer.write_platformio_project()
  File "/esphome/esphome/writer.py", line 203, in write_platformio_project
    write_platformio_ini(content)
  File "/esphome/esphome/writer.py", line 182, in write_platformio_ini
    update_storage_json()
  File "/esphome/esphome/writer.py", line 121, in update_storage_json
    clean_build()
  File "/esphome/esphome/writer.py", line 354, in clean_build
    shutil.rmtree(piolibdeps)
  File "/usr/lib/python3.9/shutil.py", line 718, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/usr/lib/python3.9/shutil.py", line 655, in _rmtree_safe_fd
    _rmtree_safe_fd(dirfd, fullname, onerror)
  File "/usr/lib/python3.9/shutil.py", line 655, in _rmtree_safe_fd
    _rmtree_safe_fd(dirfd, fullname, onerror)
  File "/usr/lib/python3.9/shutil.py", line 655, in _rmtree_safe_fd
    _rmtree_safe_fd(dirfd, fullname, onerror)
  [Previous line repeated 1 more time]
  File "/usr/lib/python3.9/shutil.py", line 675, in _rmtree_safe_fd
    onerror(os.unlink, fullname, sys.exc_info())
  File "/usr/lib/python3.9/shutil.py", line 673, in _rmtree_safe_fd
    os.unlink(entry.name, dir_fd=topfd)
OSError: [Errno 5] Input/output error: 'install-arduino-ide.sh'

The configuration YAML has not changed since compilation last worked. Other devices compile fine.

What I’ve Tried

  • If I copy and paste the YAML to a new device with a new name it compiles fine, but if I attempt to rename that device back to the original hostname using “Rename hostname” under the device menu it also fails.
  • I have removed the ESPHome Add-On and deleted any left over files with ESPHome in the name. I’ve then reinstalled the add on and manually set every device back up by copying and pasting the YAML file from a backup.

Hardware

  • Home Assistant 2023.5.4
  • Supervisor 2023.04.1
  • Operating System 10.1
  • Generic x86-64

It seems that some device directories are corrupted, so they will not compile under the affected name / file path but I do not know how to troubleshoot further, so I am turning to the community for help. Thanks.