Error repeats even after I reinstalled UBUNTU

bench@devil:~$ bench init erpnext && cd erpnext
INFO:bench.utils:virtualenv -q env -p /usr/bin/python
Already using interpreter /usr/bin/python
INFO:bench.utils:env/bin/pip -q install --upgrade pip
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won’t be maintained after that date. A future version of pip will drop support for Python 2.7.
WARNING: The directory ‘/opt/bench/.cache/pip/http’ or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
WARNING: The directory ‘/opt/bench/.cache/pip’ or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
INFO:bench.utils:env/bin/pip -q install wheel
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won’t be maintained after that date. A future version of pip will drop support for Python 2.7.
WARNING: The directory ‘/opt/bench/.cache/pip/http’ or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
WARNING: The directory ‘/opt/bench/.cache/pip’ or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
INFO:bench.utils:env/bin/pip -q install six
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won’t be maintained after that date. A future version of pip will drop support for Python 2.7.
WARNING: The directory ‘/opt/bench/.cache/pip/http’ or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
WARNING: The directory ‘/opt/bench/.cache/pip’ or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
INFO:bench.utils:env/bin/pip -q install -e git+https://github.com/frappe/python-pdfkit.git#egg=pdfkit
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won’t be maintained after that date. A future version of pip will drop support for Python 2.7.
WARNING: The directory ‘/opt/bench/.cache/pip/http’ or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
WARNING: The directory ‘/opt/bench/.cache/pip’ or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
INFO:bench.app:getting app frappe
INFO:bench.utils:git clone https://github.com/frappe/frappe.git --origin upstream
Cloning into ‘frappe’…
remote: Enumerating objects: 49, done.
remote: Counting objects: 100% (49/49), done.
remote: Compressing objects: 100% (49/49), done.
remote: Total 178884 (delta 24), reused 7 (delta 0), pack-reused 178835
Receiving objects: 100% (178884/178884), 201.23 MiB | 1.82 MiB/s, done.
Resolving deltas: 100% (136864/136864), done.
(‘installing’, u’frappe’)
INFO:bench.app:installing frappe
INFO:bench.utils:erpnext/env/bin/pip install -q -e erpnext/apps/frappe
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won’t be maintained after that date. A future version of pip will drop support for Python 2.7.
WARNING: The directory ‘/opt/bench/.cache/pip/http’ or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
WARNING: The directory ‘/opt/bench/.cache/pip’ or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
WARNING: Building wheel for markdown2 failed: [Errno 13] Permission denied: ‘/opt/bench/.cache/pip/wheels/07’
WARNING: Building wheel for maxminddb-geolite2 failed: [Errno 13] Permission denied: ‘/opt/bench/.cache/pip/wheels/94’
WARNING: Building wheel for html2text failed: [Errno 13] Permission denied: ‘/opt/bench/.cache/pip/wheels/eb’
WARNING: Building wheel for email-reply-parser failed: [Errno 13] Permission denied: ‘/opt/bench/.cache/pip/wheels/d1’
WARNING: Building wheel for watchdog failed: [Errno 13] Permission denied: ‘/opt/bench/.cache/pip/wheels/e2’
WARNING: Building wheel for bleach-whitelist failed: [Errno 13] Permission denied: ‘/opt/bench/.cache/pip/wheels/be’
WARNING: Building wheel for zxcvbn-python failed: [Errno 13] Permission denied: ‘/opt/bench/.cache/pip/wheels/0d’
WARNING: Building wheel for PyPDF2 failed: [Errno 13] Permission denied: ‘/opt/bench/.cache/pip/wheels/53’
WARNING: Building wheel for openpyxl failed: [Errno 13] Permission denied: ‘/opt/bench/.cache/pip/wheels/82’
WARNING: Building wheel for pyqrcode failed: [Errno 13] Permission denied: ‘/opt/bench/.cache/pip/wheels/54’
WARNING: Building wheel for pypng failed: [Errno 13] Permission denied: ‘/opt/bench/.cache/pip/wheels/a4’
WARNING: Building wheel for future failed: [Errno 13] Permission denied: ‘/opt/bench/.cache/pip/wheels/0c’
WARNING: Building wheel for google-api-python-client failed: [Errno 13] Permission denied: ‘/opt/bench/.cache/pip/wheels/6c’
WARNING: Building wheel for maxminddb failed: [Errno 13] Permission denied: ‘/opt/bench/.cache/pip/wheels/58’
WARNING: Building wheel for simplegeneric failed: [Errno 13] Permission denied: ‘/opt/bench/.cache/pip/wheels/a9’
WARNING: Building wheel for PyYAML failed: [Errno 13] Permission denied: ‘/opt/bench/.cache/pip/wheels/ad’
WARNING: Building wheel for pathtools failed: [Errno 13] Permission denied: ‘/opt/bench/.cache/pip/wheels/0b’
WARNING: Building wheel for et-xmlfile failed: [Errno 13] Permission denied: ‘/opt/bench/.cache/pip/wheels/2a’
WARNING: Building wheel for cssutils failed: [Errno 13] Permission denied: ‘/opt/bench/.cache/pip/wheels/a4’
WARNING: Building wheel for httplib2 failed: [Errno 13] Permission denied: ‘/opt/bench/.cache/pip/wheels/9d’
WARNING: Building wheel for scandir failed: [Errno 13] Permission denied: ‘/opt/bench/.cache/pip/wheels/91’
WARNING: Building wheel for pycparser failed: [Errno 13] Permission denied: ‘/opt/bench/.cache/pip/wheels/f2’
Updating node packages…
INFO:bench.utils:yarn install
yarn install v1.16.0
warning Skipping preferred cache folder “/opt/bench/.cache/yarn” because it is not writable.
warning Selected the next writable cache folder in the list, will be “/tmp/.yarn-cache-1001”.
[1/4] Resolving packages…
[2/4] Fetching packages…
[3/4] Linking dependencies…
warning " > bootstrap@4.3.1" has unmet peer dependency “jquery@1.9.1 - 3”.
warning " > bootstrap@4.3.1" has unmet peer dependency “popper.js@^1.14.7”.
[4/4] Building fresh packages…
[1/2] ⠈ cypress
error /opt/bench/erpnext/apps/frappe/node_modules/cypress: Command failed.
Exit code: 1
Command: node index.js --exec install
Arguments:
Directory: /opt/bench/erpnext/apps/frappe/node_modules/cypress
Output:
Cypress cannot write to the cache directory due to file permissions

Failed to access /opt/bench/.cache/Cypress:

EACCES: permission denied, mkdir ‘/opt/bench/.cache/Cypress’

Platform: linux (Ubuntu Linux - 18.04)
Cypress Version: 3.1.5

Traceback (most recent call last):
File “/usr/local/bin/bench”, line 11, in
load_entry_point(‘bench’, ‘console_scripts’, ‘bench’)()
File “/opt/bench/bench-repo/bench/cli.py”, line 40, in cli
bench_command()
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 764, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 717, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 555, in invoke
return callback(*args, **kwargs)
File “/opt/bench/bench-repo/bench/commands/make.py”, line 30, in init
python = python)
File “/opt/bench/bench-repo/bench/utils.py”, line 83, in init
update_node_packages(bench_path=path)
File “/opt/bench/bench-repo/bench/utils.py”, line 452, in update_node_packages
update_yarn_packages(bench_path)
File “/opt/bench/bench-repo/bench/utils.py”, line 465, in update_yarn_packages
exec_cmd(‘yarn install’, cwd=app_path)
File “/opt/bench/bench-repo/bench/utils.py”, line 159, in exec_cmd
raise CommandFailedError(cmd)
bench.utils.CommandFailedError: yarn install
bench@devil:~$ sudo apt-get install yarn
Reading package lists… Done
Building dependency tree
Reading state information… Done
yarn is already the newest version (1.16.0-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

what is the full process you followed to install bench?

BTW to install anything in the opt folder you need either permissions to said folder (run sudo chown -R frappe /opt/bench) or run bench with sudo.

Closing this due to inactivity. If the issue persists and you think it might be a bug, open a GitHub issue : )