Permission problems after upgrading to 32.1 from 31.1

I had a working HA before upgrading to 32.1, installed from Hasbian so permission’s were set as per instruction for virtualenv. I get the follow error. Any advice would be appreciated. Thanks.

pi@raspberrypi:/srv/hass $ sudo -u hass -H /srv/hass/hass_venv/bin/hass

Config directory: /home/hass/.homeassistant
INFO:homeassistant.config:Upgrading config directory from 0.31.1 to 0.32.1
Traceback (most recent call last):
  File "/srv/hass/hass_venv/bin/hass", line 11, in <module>
    sys.exit(main())
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/__main__.py", line 380, in main
    exit_code = setup_and_run_hass(config_dir, args)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/__main__.py", line 293, in setup_and_run_hass
    log_rotate_days=args.log_rotate_days)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/bootstrap.py", line 457, in from_config_file
    hass.loop.run_until_complete(future)
  File "/usr/lib/python3.4/asyncio/base_events.py", line 276, in run_until_complete
    return future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/bootstrap.py", line 448, in _async_init_from_config_file
    config_path, hass, verbose, skip_pip, log_rotate_days)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/bootstrap.py", line 490, in async_from_config_file
    config_dict, hass, enable_log=False, skip_pip=skip_pip)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/bootstrap.py", line 385, in async_from_config_dict
    None, conf_util.process_ha_config_upgrade, hass)
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/config.py", line 251, in process_ha_config_upgrade
    shutil.rmtree(lib_path)
  File "/srv/hass/hass_venv/lib/python3.4/shutil.py", line 463, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/srv/hass/hass_venv/lib/python3.4/shutil.py", line 401, in _rmtree_safe_fd
    _rmtree_safe_fd(dirfd, fullname, onerror)
  File "/srv/hass/hass_venv/lib/python3.4/shutil.py", line 421, in _rmtree_safe_fd
    onerror(os.unlink, fullname, sys.exc_info())
  File "/srv/hass/hass_venv/lib/python3.4/shutil.py", line 419, in _rmtree_safe_fd
    os.unlink(name, dir_fd=topfd)
PermissionError: [Errno 13] Permission denied: 'PKG-INFO'
1 Like

Similar problem here:

marek@ubuntumate:/srv/hass/lib/python3.4$ sudo -u hass -H /srv/hass/bin/hass
Config directory: /home/hass/.homeassistant
INFO:homeassistant.config:Upgrading config directory from 0.31.1 to 0.32.2
Traceback (most recent call last):
  File "/srv/hass/bin/hass", line 11, in <module>
    sys.exit(main())
  File "/srv/hass/lib/python3.4/site-packages/homeassistant/__main__.py", line 380, in main
    exit_code = setup_and_run_hass(config_dir, args)
  File "/srv/hass/lib/python3.4/site-packages/homeassistant/__main__.py", line 293, in setup_and_run_hass
    log_rotate_days=args.log_rotate_days)
  File "/srv/hass/lib/python3.4/site-packages/homeassistant/bootstrap.py", line 457, in from_config_file
    hass.loop.run_until_complete(future)
  File "/usr/lib/python3.4/asyncio/base_events.py", line 343, in run_until_complete
    return future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/srv/hass/lib/python3.4/site-packages/homeassistant/bootstrap.py", line 448, in _async_init_from_config_file
    config_path, hass, verbose, skip_pip, log_rotate_days)
  File "/srv/hass/lib/python3.4/site-packages/homeassistant/bootstrap.py", line 490, in async_from_config_file
    config_dict, hass, enable_log=False, skip_pip=skip_pip)
  File "/srv/hass/lib/python3.4/site-packages/homeassistant/bootstrap.py", line 385, in async_from_config_dict
    None, conf_util.process_ha_config_upgrade, hass)
  File "/usr/lib/python3.4/asyncio/futures.py", line 385, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 288, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/hass/lib/python3.4/site-packages/homeassistant/config.py", line 251, in process_ha_config_upgrade
    shutil.rmtree(lib_path)
  File "/srv/hass/lib/python3.4/shutil.py", line 468, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/srv/hass/lib/python3.4/shutil.py", line 406, in _rmtree_safe_fd
    _rmtree_safe_fd(dirfd, fullname, onerror)
  File "/srv/hass/lib/python3.4/shutil.py", line 406, in _rmtree_safe_fd
    _rmtree_safe_fd(dirfd, fullname, onerror)
  File "/srv/hass/lib/python3.4/shutil.py", line 426, in _rmtree_safe_fd
    onerror(os.unlink, fullname, sys.exc_info())
  File "/srv/hass/lib/python3.4/shutil.py", line 424, in _rmtree_safe_fd
    os.unlink(name, dir_fd=topfd)
PermissionError: [Errno 13] Permission denied: 'COPYING.LIB'

Solved, problem was in bad installation of bluepy (bad ownership - not hass user). Chown -R hass on folders with it and problem is gone. Marek

I tried running chown -R hass /srv/hass/hass_venv/lib/ and confirmed hass is the owner but still get the same error. I tried to find bluepy but can’t find that file. (isn’t this a bluetooth related file?) I can currently downgrade to 31.1 and have HA back to working. Any other suggestions? thanks

I solved the installation of 32.2 by changing the user permissions on /usr/lib. I changed it with WinSCP. Thanks marekobi for pointing in the right direction

Cheers! I’ve just had this problem and indeed, the permissions where all wrong. Some folders in /home/hass/.homeassistant were set up to the root user.
Probably because I always mount the .homeassistant folder when editing the configs.

A simple chown hass:hass .homeassistant/ -R fixed it! Thanks!

1 Like

Did that but still with problems updating … any ideas ?

Nov 22 14:32:58 raspberrypi hass[1809]: onerror(os.unlink, fullname, sys.exc_info())
Nov 22 14:32:58 raspberrypi hass[1809]: File "/srv/hass/hass_venv/lib/python3.4/shutil.py", line   419, in _rmtree_safe_fd
Nov 22 14:32:58 raspberrypi hass[1809]: os.unlink(name, dir_fd=topfd)
Nov 22 14:32:58 raspberrypi hass[1809]: PermissionError: [Errno 13] Permission denied: 'WHEEL'
Nov 22 14:32:58 raspberrypi systemd[1]: home-assistant.service: main process exited, code=exited, status=1/FAILURE
Nov 22 14:32:58 raspberrypi systemd[1]: Unit home-assistant.service entered failed state.

I solved my problem by changing the permission in two locations which were determined from the log. I changed the permission in the two locations with WINScp allowing full write read permission 777 but I think it can be done with below.

To give hass ownership

chown -R hass /srv/hass/hass_venv/
chown -R hass /usr/lib/

if that doesn’t work, you might try to give full read write access to everyone

chmod -R 777 /srv/hass/hass_venv/
chmod -R 777 /usr/lib/

For the love of god and all that is holy DO NOT EVER DO chmod -R 777 /usr/lib!!!

Even if this ‘fixed’ one problem, now you have a machine begging to be compromised.

You are running your install as a user / in a location you don’t have permission to edit. chmod 777 should be used almost never, and certainly not recursively on system locations like /usr/lib