Error while doing bench update (Permission Error)

Hi,
I am doing a bench update and it is giving me the below error, seems like it is related to Permission. May anyone, please help me in this context?

vishnu@vishnu-VirtualBox:/home/frappe/frappe-bench$ bench update
INFO:bench.utils:updating bench
error: cannot open .git/FETCH_HEAD: Permission denied

Traceback (most recent call last):
  File "/usr/local/bin/bench", line 11, in <module>
    load_entry_point('bench', 'console_scripts', 'bench')()
  File "/home/frappe/.bench/bench/cli.py", line 40, in cli
    bench_command()
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/.bench/bench/commands/update.py", line 34, in update
    update_bench()
  File "/home/frappe/.bench/bench/utils.py", line 227, in update_bench
    exec_cmd("git pull", cwd=cwd)
  File "/home/frappe/.bench/bench/utils.py", line 127, in exec_cmd
    raise CommandFailedError(cmd)
bench.utils.CommandFailedError: git pull

Regards
Ruchin Sharma

@ishanloya
After using these commands I got the below error:

Traceback (most recent call last):
  File "/usr/local/bin/bench", line 11, in <module>
    load_entry_point('bench', 'console_scripts', 'bench')()
  File "/home/frappe/.bench/bench/cli.py", line 40, in cli
    bench_command()
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1057, in invoke
    Command.invoke(self, ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/.bench/bench/commands/__init__.py", line 21, in bench_command
    setup_logging(bench_path=bench_path)
  File "/home/frappe/.bench/bench/utils.py", line 265, in setup_logging
    hdlr = logging.FileHandler(log_file)
  File "/usr/lib/python2.7/logging/__init__.py", line 903, in __init__
    StreamHandler.__init__(self, self._open())
  File "/usr/lib/python2.7/logging/__init__.py", line 928, in _open
    stream = open(self.baseFilename, self.mode)
IOError: [Errno 13] Permission denied: '/home/frappe/frappe-bench/logs/bench.log'

Regards
Ruchin Sharma

@ruchin78 how about if you try the chown commands without the user group like so…also, are the paths/user in the following steps the same as yours?

sudo chown -R frappe /home/frappe/.bench
sudo chown -R frappe /home/frappe/frappe-bench
cd /home/frappe/.bench
git reset --hard
git pull
cd /home/frappe/frappe-bench
bench update

1 Like

@ruchin78 also refer to this topic

@ishanloya
I am still getting error.

vishnu@vishnu-VirtualBox:/home/frappe/frappe-bench$ sudo bench update
INFO:bench.utils:updating bench
Already up-to-date.
Requirement already satisfied (use --upgrade to upgrade): Pillow in ./env/lib/python2.7/site-packages
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
INFO:bench.app:pulling frappe
From https://github.com/frappe/frappe
 * branch            master     -> FETCH_HEAD
Updating 8edb00f..0672f50
error: Your local changes to the following files would be overwritten by merge:
    frappe/__init__.py
    frappe/api.py
    frappe/app.py
    frappe/auth.py
    frappe/boot.py
    frappe/build.py
    frappe/client.py
    frappe/commands/docs.py
    frappe/commands/translate.py
    frappe/commands/utils.py
    frappe/config/core.py
    frappe/config/setup.py
    frappe/core/doctype/docfield/docfield.json
    frappe/core/doctype/docperm/docperm.json
    frappe/core/doctype/docshare/docshare.py
    frappe/core/doctype/docshare/test_docshare.py
    frappe/core/doctype/doctype/doctype.js
    frappe/core/doctype/doctype/doctype.json
    frappe/core/doctype/doctype/doctype.py
    frappe/core/doctype/file/file.json
    frappe/core/doctype/page/page.py
    frappe/core/doctype/report/report.py
    frappe/core/doctype/report/test_report.py
    frappe/core/doctype/role/role.json
    frappe/core/doctype/role/test_records.json
    frappe/core/doctype/scheduler_log/README.md
    frappe/core/doctype/scheduler_log/__init__.py
    frappe/core/doctype/scheduler_log/scheduler_log.js
    frappe/core/doctype/scheduler_log/scheduler_log.json
    frappe/core/doctype/scheduler_log/scheduler_log.py
    frappe/core/doctype/scheduler_log/scheduler_log_list.js
    frappe/core/doctype/scheduler_log/test_scheduler_log.py
    frappe/core/doctype/system_settings/system_settings.js
    frappe/core/doctype/system_settings/system_settings.json
    frappe/core/doctype/translation/test_translation.py
    frappe/core/doctype/translation/translation.js
    frappe/core/doctype/translation/translation.json
    frappe/core/doctype/translation/translation.py
    frappe/core/doctype/user/test_user.py
    frappe/core/doctype/user/user.js
    frappe/core/doctype/user/user.json
    frappe/core/doctype/user/user.py
    frappe/core/notifications.py
    frappe/core/page/data_import_tool/data_import_main.html
    frappe/core/page/data_import_tool/data_import_tool.js
    frappe/core/page/data_import_tool/data_import_tool.py
    frappe/core/page/data_import_tool/data_import_tool_columns.html
    frappe/core/page/data_import_tool/importer.py
    frappe/core/page/permission_manager/permission_manager.py
    frappe/core/report/permitted_documents_for_user/permitted_documents_for_user.js
    frappe/custom/doctype/custom_script/custom_script.json
    frappe/custom/doctype/customize_form/customize_form.js
    frappe/custom/doctype/customize_form/customize_form.json
    frappe/custom/doctype/customize_form/customize_form.py
    frappe/custom/doctype/customize_form/test_customize_form.py
    frappe/custom/doctype/customize_form_field/customize_form_field.json
    frappe/data/Framework.sql
    frappe/data/languages.txt
    frappe/defaults.py
    frappe/desk/desk_page.py
    frappe/desk/doctype/bulk_update/bulk_update.js
    frappe/desk/doctype/bulk_update/bulk_update.json
    frappe/desk/doctype/bulk_update/bulk_update.py
    frappe/desk/doctype/desktop_icon/desktop_icon.py
    frappe/desk/doctype/event/event.py
    frappe/desk/doctype/note/note.js
    frappe/desk/doctype/note/note.json
    frappe/desk/doctype/note/note.py
    frappe/desk/form/meta.py
    frappe/desk/page/backups/backups.js
    frappe/desk/page/backups/backups.py
    frappe/desk/page/chat/chat.js
    frappe/desk/page/modules/modules.js
    frappe/desk/query_report.py
    frappe/desk/treeview.py
    frappe/docs/assets/query-report-out.png
    frappe/docs/assets/query-report.png
    frappe/docs/index.html
    frappe/docs/user/fr/guides/.txt
    frappe/docs/user/fr/guides/__init__.py
    frappe/docs/user/fr/guides/app-development/__init__.py
    frappe/docs/user/fr/guides/app-development/adding-module-icons-on-desktop.md
    frappe/docs/user/fr/guides/app-development/custom-module-icon.md
    frappe/docs/user/fr/guides/app-development/dialogs-types.md
    frappe/docs/user/fr/guides/app-development/executing-code-on-doctype-events.md
    frappe/docs/user/fr/guides/app-development/fetch-custom-field-value-from-master-to-all-related-transactions.md
    frappe/docs/user/fr/guides/app-development/generating-docs.md
    frappe/docs/user/fr/guides/app-development/how-enable-developer-mode-in-frappe.md
    frappe/docs/user/fr/guides/app-development/how-to-create-custom-fields-during-app-installation.md
    frappe/docs/user/fr/guides/app-development/how-to-improve-a-standard-control.md
    frappe/doc
Aborting
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 11, in <module>
    load_entry_point('bench', 'console_scripts', 'bench')()
  File "/home/frappe/.bench/bench/cli.py", line 40, in cli
    bench_command()
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/.bench/bench/commands/update.py", line 62, in update
    _update(pull, patch, build, bench, auto, restart_supervisor, requirements, no_backup, upgrade, force=force, reset=reset)
  File "/home/frappe/.bench/bench/commands/update.py", line 78, in _update
    pull_all_apps(bench_path=bench_path, reset=reset)
  File "/home/frappe/.bench/bench/app.py", line 146, in pull_all_apps
    remote=remote, branch=get_current_branch(app, bench_path=bench_path)), cwd=app_dir)
  File "/home/frappe/.bench/bench/utils.py", line 127, in exec_cmd
    raise CommandFailedError(cmd)
bench.utils.CommandFailedError: git pull  upstream master

Regards
Ruchin Sharma

@ruchin78

i had the same issue. i’ve tried all solutions everybody mentioned here. after i’ve changed whole bench directory permissions using sudo chmod -R 777 my-bench it worked. thanks everybody :v: :v: