Cannot update home assistant in venv

Hi all,
I am trying to update home assistant from 2021.2.3 to the latest version using the following commands:

sudo -u homeassistant -H -s
source /srv/homeassistant/bin/activate
pip3 install --upgrade homeassistant

but I get the following error:

ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: 'RECORD'
Consider using the `--user` option or check the permissions.

Any suggestion on how to approach the problem? Many thanks!

What version of Python?

@giovanni: you have to stop the running HA

sudo systemctl stop [email protected]

Complete procedure:

sudo systemctl stop [email protected]
sudo su -s /bin/bash homeassistant
source /srv/homeassistant/bin/activate
pip3 install --upgrade homeassistant
exit
sudo systemctl start [email protected]

Python 3.9.1

I tried this procedure but the update still fails :frowning:

You get permission denied Are some of the files owned by root instead of the user running HA?

On @Prodigyplace’s suggestion maybe check something like

find /srv/homeassistant -ls | awk ‘{print $5, $11}’ | grep -v homeassistant

Which is just a (messy) check for any file in ~homeassistant that is not owned by homeassistant. The find should come up empty.

1 Like

It does come up empty

Now I’m guessing. Perhaps adding some verbosity to the pip3 command will tell us which ‘RECORD’ is the one that’s a problem. Mine look to be all -rw-r–r–

sudo systemctl stop [email protected]
sudo su -s /bin/bash homeassistant
source /srv/homeassistant/bin/activate
pip3 install -vvv --upgrade homeassistant # and see if anything new is learned
exit
sudo systemctl start [email protected]

This is the verbose output:

ERROR: Could not install packages due to an EnvironmentError.
Consider using the `--user` option or check the permissions.
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 397, in run
    installed = install_given_reqs(
  File "/srv/homeassistant/lib/python3.9/site-packages/pip/_internal/req/__init__.py", line 99, in install_given_reqs
    uninstalled_pathset.commit()
  File "/srv/homeassistant/lib/python3.9/site-packages/pip/_internal/req/req_uninstall.py", line 450, in commit
    self._moved_paths.commit()
  File "/srv/homeassistant/lib/python3.9/site-packages/pip/_internal/req/req_uninstall.py", line 290, in commit
    save_dir.cleanup()
  File "/srv/homeassistant/lib/python3.9/site-packages/pip/_internal/utils/temp_dir.py", line 199, in cleanup
    rmtree(ensure_text(self._path))
  File "/srv/homeassistant/lib/python3.9/site-packages/pip/_vendor/retrying.py", line 49, in wrapped_f
    return Retrying(*dargs, **dkw).call(f, *args, **kw)
  File "/srv/homeassistant/lib/python3.9/site-packages/pip/_vendor/retrying.py", line 212, in call
    raise attempt.get()
  File "/srv/homeassistant/lib/python3.9/site-packages/pip/_vendor/retrying.py", line 247, in get
    six.reraise(self.value[0], self.value[1], self.value[2])
  File "/srv/homeassistant/lib/python3.9/site-packages/pip/_vendor/six.py", line 703, in reraise
    raise value
  File "/srv/homeassistant/lib/python3.9/site-packages/pip/_vendor/retrying.py", line 200, in call
    attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
  File "/srv/homeassistant/lib/python3.9/site-packages/pip/_internal/utils/misc.py", line 138, in rmtree
    shutil.rmtree(dir, ignore_errors=ignore_errors,
  File "/usr/local/lib/python3.9/shutil.py", line 718, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/usr/local/lib/python3.9/shutil.py", line 675, in _rmtree_safe_fd
    onerror(os.unlink, fullname, sys.exc_info())
  File "/usr/local/lib/python3.9/shutil.py", line 673, in _rmtree_safe_fd
    os.unlink(entry.name, dir_fd=topfd)
PermissionError: [Errno 13] Permission denied: 'RECORD'
WARNING: You are using pip version 20.2.4; however, version 21.1.3 is available.
You should consider upgrading via the '/srv/homeassistant/bin/python3 -m pip install --upgrade pip' command.
Removed build tracker: '/tmp/pip-req-tracker-3dsmw2kb'

Apparently, you need to upgrade pip:

sudo pip3 install --upgrade pip

Source:
Permision problem pip (python-forum.io)

Success!!! I had to update pip through:

/srv/homeassistant/bin/python3 -m pip install --upgrade pip

Thank you all for helping :slight_smile: