'EACCES: permission denied, mkdir '/var/www/ghost/versions/4.10.2''

I’m getting this error when trying to update Ghost, please help. 'EACCES: permission denied, mkdir '/var/www/ghost/versions/4.10.2''


Message: 'EACCES: permission denied, mkdir '/var/www/ghost/versions/4.10.2''

Stack: Error: EACCES: permission denied, mkdir '/var/www/ghost/versions/4.10.2'
    at Object.mkdirSync (fs.js:987:3)
    at Object.module.exports.makeDirSync (/usr/lib/node_modules/ghost-cli/node_modules/fs-extra/lib/mkdirs/make-dir.js:101:15)
    at Task.download [as task] (/usr/lib/node_modules/ghost-cli/lib/tasks/yarn-install.js:49:12)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
Path: /var/www/ghost/versions/4.10.2
Debug Information:
    OS: Ubuntu, v20.04.2 LTS
    Node Version: v14.16.1
    Ghost Version: 4.6.0
    Ghost-CLI Version: 1.17.3
    Environment: production
    Command: 'ghost update'

I updated the ownership of the directory and it worked

sudo chown -R user:user /var/www/ghost/

there is ghost-mgr in DO instances, just use that user

sudo -i -u ghost-mgr
su ghost-mgr (if you’re root)