Bench Update: Issues with permissions

ok what’s going on I am making no changes to frappe, bench, erpnext and I responded to yesterdays error with a stash why the failure again today?
sudo bench update
INFO:bench.utils:updating bench
Already up-to-date.
Requirement already satisfied: Pillow in ./env/lib/python2.7/site-packages
INFO:bench.app:pulling frappe
From https://github.com/frappe/frappe

  • branch master -> FETCH_HEAD
    Already up-to-date.
    INFO:bench.app:pulling erpnext
    remote: Counting objects: 81, done.
    remote: Compressing objects: 100% (81/81), done.
    error: insufficient permission for adding an object to repository database .git/objects
    fatal: failed to write object
    fatal: unpack-objects failed
    Traceback (most recent call last):
    File “/bin/bench”, line 11, in
    load_entry_point(‘bench’, ‘console_scripts’, ‘bench’)()
    File “/home/frappe/.bench/bench/cli.py”, line 40, in cli
    bench_command()
    File “/usr/lib64/python2.7/site-packages/click/core.py”, line 716, in call
    return self.main(*args, **kwargs)
    File “/usr/lib64/python2.7/site-packages/click/core.py”, line 696, in main
    rv = self.invoke(ctx)
    File “/usr/lib64/python2.7/site-packages/click/core.py”, line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File “/usr/lib64/python2.7/site-packages/click/core.py”, line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
    File “/usr/lib64/python2.7/site-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

You don’t need sudo in bench update, did you try without sudo

Seems like a problem with permissions: stackoverflow discussion

This has been a problem since I started working with this app inconsistent install instruction based on the flavor of Linux. This is Centos as it was a disaster with Ubuntu. so far Centos seems to be the most consistent. This was installed using the install script and yes sudo is necessary under Centos as without it does not work I have installed over 50 times in the last few months trying to achieve a baseline so I am very familiar with frappes nuances. This has something to do with changes you have made in the either git or backend that is getting it out of synch any further ideas?
bench update
Traceback (most recent call last):
File “/usr/bin/bench”, line 11, in
load_entry_point(‘bench’, ‘console_scripts’, ‘bench’)()
File “/home/frappe/.bench/bench/cli.py”, line 40, in cli
bench_command()
File “/usr/lib64/python2.7/site-packages/click/core.py”, line 716, in call
return self.main(*args, **kwargs)
File “/usr/lib64/python2.7/site-packages/click/core.py”, line 696, in main
rv = self.invoke(ctx)
File “/usr/lib64/python2.7/site-packages/click/core.py”, line 1057, in invoke
Command.invoke(self, ctx)
File “/usr/lib64/python2.7/site-packages/click/core.py”, line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/lib64/python2.7/site-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/lib64/python2.7/logging/init.py”, line 902, in init
StreamHandler.init(self, self._open())
File “/usr/lib64/python2.7/logging/init.py”, line 925, in _open
stream = open(self.baseFilename, self.mode)
IOError: [Errno 13] Permission denied: ‘/home/frappe/frappe-bench/logs/bench.log’

If I stash this I suspect update will work as it did yesterday.

Try this:

Update permissions for logs folder in frappe-bench using
sudo chown -R frappe:frappe logs

done
sudo bench update
INFO:bench.utils:updating bench
Already up-to-date.
Requirement already satisfied: Pillow in ./env/lib/python2.7/site-packages
INFO:bench.app:pulling frappe
From https://github.com/frappe/frappe

  • branch master -> FETCH_HEAD
    Already up-to-date.
    INFO:bench.app:pulling erpnext
    remote: Counting objects: 81, done.
    remote: Compressing objects: 100% (81/81), done.
    error: insufficient permission for adding an object to repository database .git/objects
    fatal: failed to write object
    fatal: unpack-objects failed
    Traceback (most recent call last):
    File “/bin/bench”, line 11, in
    load_entry_point(‘bench’, ‘console_scripts’, ‘bench’)()
    File “/home/frappe/.bench/bench/cli.py”, line 40, in cli
    bench_command()
    File “/usr/lib64/python2.7/site-packages/click/core.py”, line 716, in call
    return self.main(*args, **kwargs)
    File “/usr/lib64/python2.7/site-packages/click/core.py”, line 696, in main
    rv = self.invoke(ctx)
    File “/usr/lib64/python2.7/site-packages/click/core.py”, line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File “/usr/lib64/python2.7/site-packages/click/core.py”, line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
    File “/usr/lib64/python2.7/site-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

bench update without sudo

as I have said before bench update on centos does not work without sudo I have installed this app over 50 times and this is the closet to functional I have been able to get it and until this week was working well until I tried bench update which complained about GitHub issue if you know how to fix once and for all I’m all on board…

Did you do a manual install or from the script?

production script

@imllc the way bench is designed, you need to run your updates with user frappe.

If you have a custom setup, it is hard for us to debug this.

Not custom install straight out of the box production script and there is no password file so the only way to get frappe password is to change it I have posted on this before. I arrived at using sudo because it was the only way I could find to make it work on centos as I said before unbuntu was even worse.

No need to change frappe password to run the update. Use sudo to change to the frappe account with:

sudo -i -u frappe bash

2 Likes

Still does not work:
[frappe@moneta frappe-bench]$ bench update
INFO:bench.utils:updating bench
Already up-to-date.
remote: Counting objects: 106, done.
remote: Compressing objects: 100% (44/44), done.
remote: Total 106 (delta 69), reused 55 (delta 55), pack-reused 7
Receiving objects: 100% (106/106), 115.13 KiB | 0 bytes/s, done.
Resolving deltas: 100% (69/69), completed with 52 local objects.
From https://github.com/frappe/frappe
ce4e170…ee02258 master -> upstream/master
610ea6b…4bd2285 develop -> upstream/develop
ce4e170…a7477d5 hotfix -> upstream/hotfix
Requirement already satisfied: Pillow in ./env/lib/python2.7/site-packages
INFO:bench.app:pulling frappe
From https://github.com/frappe/frappe

  • branch master -> FETCH_HEAD
    Updating ce4e170…ee02258
    Fast-forward
    frappe/commands/site.py | 22 ++++++++++++++++++++++
    1 file changed, 22 insertions(+)
    INFO:bench.app:pulling erpnext
    remote: Counting objects: 81, done.
    error: insufficient permission for adding an object to repository database .git/objects
    fatal: failed to write object
    fatal: unpack-objects failed
    Traceback (most recent call last):
    File “/bin/bench”, line 11, in
    load_entry_point(‘bench’, ‘console_scripts’, ‘bench’)()
    File “/home/frappe/.bench/bench/cli.py”, line 40, in cli
    bench_command()
    File “/usr/lib64/python2.7/site-packages/click/core.py”, line 716, in call
    return self.main(*args, **kwargs)
    File “/usr/lib64/python2.7/site-packages/click/core.py”, line 696, in main
    rv = self.invoke(ctx)
    File “/usr/lib64/python2.7/site-packages/click/core.py”, line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File “/usr/lib64/python2.7/site-packages/click/core.py”, line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
    File “/usr/lib64/python2.7/site-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

After nothing suggested the commands below worked.
As you can see you need to know frappe password to proceed.
and I had to run as root -why-?

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

[frappe@moneta frappe-bench]$ sudo chown -R frappe:frappe /home/frappe/.bench
[sudo] password for frappe:
[frappe@moneta frappe-bench]$ su root
Password:
[root@moneta frappe-bench]# sudo chown -R frappe:frappe /home/frappe/.bench
[root@moneta frappe-bench]# sudo chown -R frappe:frappe /home/frappe/frappe-bench
[root@moneta frappe-bench]# cd /home/frappe/.bench
[root@moneta .bench]# git reset --hard
HEAD is now at 2b67155 Merge pull request #345 from shreyasp/max-redis-mem
[root@moneta .bench]# git pull
Already up-to-date.
[root@moneta .bench]# cd /home/frappe/frappe-bench

[root@moneta frappe-bench]# bench update
INFO:bench.utils:updating bench
Already up-to-date.
Requirement already satisfied: Pillow in ./env/lib/python2.7/site-packages
INFO:bench.app:pulling frappe
From https://github.com/frappe/frappe

  • branch master -> FETCH_HEAD
    Already up-to-date.
    INFO:bench.app:pulling erpnext
    remote: Counting objects: 81, done.
    remote: Total 81 (delta 48), reused 48 (delta 48), pack-reused 33
    Unpacking objects: 100% (81/81), done.
    From https://github.com/frappe/erpnext
  • branch master -> FETCH_HEAD
    Updating 8132be2…6fc850d
    Fast-forward
    erpnext/init.py | 2 ±
    erpnext/accounts/doctype/account/account_tree.js | 5 +±-
    erpnext/accounts/doctype/journal_entry/journal_entry.py | 2 ±
    erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py | 2 ±
    erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 2 ±
    erpnext/accounts/utils.py | 14 +++++±–
    erpnext/controllers/accounts_controller.py | 15 ++++++++++
    erpnext/hooks.py | 2 ++
    erpnext/patches/v7_0/repost_gle_for_pi_with_update_stock.py | 2 ++
    erpnext/schools/doctype/student_admission/student_admission.py | 2 ±
    erpnext/selling/sales_common.js | 3 ±
    erpnext/setup/doctype/naming_series/naming_series.py | 3 ±
    erpnext/stock/doctype/delivery_note_item/delivery_note_item.json | 61 +++++++++++++++++++++++++++++++++++±-
    erpnext/stock/doctype/item/item.py | 2 ±
    erpnext/utilities/transaction_base.py | 14 ---------
    15 files changed, 100 insertions(+), 31 deletions(-)
    INFO:bench.app:pulling paypal_integration
    From https://github.com/frappe/paypal_integration
  • branch master -> FETCH_HEAD
    Already up-to-date.
    Requirement already up-to-date: pip in ./env/lib/python2.7/site-packages
    Migrating moneta.imerecom.net
    Updating frappe : [========================================]
    Updating erpnext : [========================================]
    Updating paypal_integration : [========================================]
    Syncing help database…
    Wrote ./assets/js/print_format_v3.min.js - 18k
    Wrote ./assets/js/frappe-web.min.js - 132k
    Wrote ./assets/js/form.min.js - 138k
    Wrote ./assets/js/report.min.js - 158k
    Wrote ./assets/js/erpnext.min.js - 82k
    Wrote ./assets/css/list.min.css - 6k
    Wrote ./assets/js/item-dashboard.min.js - 6k
    Wrote ./assets/js/d3.min.js - 343k
    Wrote ./assets/css/report.min.css - 8k
    Wrote ./assets/css/frappe-web.css - 54k
    Wrote ./assets/js/list.min.js - 106k
    Wrote ./assets/js/dialog.min.js - 61k
    Wrote ./assets/js/desk.min.js - 247k
    Wrote ./assets/css/form.min.css - 4k
    Wrote ./assets/js/editor.min.js - 27k
    Wrote ./assets/css/erpnext.css - 3k
    Wrote ./assets/js/libs.min.js - 886k
    Wrote ./assets/js/erpnext-web.min.js - 2k
    Wrote ./assets/css/desk.min.css - 265k
    Wrote ./assets/css/module.min.css - 2k
    frappe-bench-workers:frappe-bench-frappe-schedule: stopped
    frappe-bench-workers:frappe-bench-frappe-default-worker-0: stopped
    frappe-bench-workers:frappe-bench-frappe-long-worker-0: stopped
    frappe-bench-workers:frappe-bench-frappe-short-worker-0: stopped
    frappe-bench-web:frappe-bench-frappe-web: stopped
    frappe-bench-web:frappe-bench-node-socketio: stopped
    frappe-bench-workers:frappe-bench-frappe-schedule: started
    frappe-bench-workers:frappe-bench-frappe-default-worker-0: started
    frappe-bench-workers:frappe-bench-frappe-long-worker-0: started
    frappe-bench-workers:frappe-bench-frappe-short-worker-0: started
    frappe-bench-web:frappe-bench-frappe-web: started
    frappe-bench-web:frappe-bench-node-socketio: started

Bench: Open source installer + admin for Frappe and ERPNext (https://erpnext.com)

Thanks @zpet this world well for my Digital Ocean droplet when moving from V9 to V10.