[Solved] Updating from 7 to 7.1

bench update error kindly help thanks

root@ubuntu-1gb-lon1:/home/frappe/frappe-bench# bench update
INFO:bench.utils:updating bench
Updating ed846f2..a8312f6
error: Your local changes to the following files would be overwritten by merge:
        bench/cli.py
        bench/commands/setup.py
        bench/commands/utils.py
        playbooks/develop/includes/wkhtmltopdf_centos.yml
        playbooks/develop/includes/wkhtmltopdf_ubuntu_debian.yml
        playbooks/develop/ubuntu.yml
        vm/ansible/roles/wkhtmltopdf/defaults/main.yml
        vm/ansible/roles/wkhtmltopdf/tasks/main.yml
Please, commit your changes or stash them before you can merge.
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 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

Hello, @Pirated,

I had this issue in the past. It has to do with how Git handles things.
It is common if you have made a manual change to the core files. However, when I ran into it the first time, I had not manually changed anything.

You need to go to your bench directory add run the following commands:

git add .
git commit

This will commit any changes in the directory and allow the upgrade to be merged in.

1 Like

got things done for each folder in /apps folder ( frappe, erpnext)

git add .
git commit
git stash
git status

Git status is now the following for each of the apps

On branch master
Your branch is up-to-date with 'upstream/master'.

nothing to commit, working directory clean

Bench Update

frappe/frappe-bench# bench update
INFO:bench.utils:updating bench
Updating ed846f2..a8312f6
error: Your local changes to the following files would be overwritten by merge:
        bench/cli.py
        bench/commands/setup.py
        bench/commands/utils.py
        playbooks/develop/includes/wkhtmltopdf_centos.yml
        playbooks/develop/includes/wkhtmltopdf_ubuntu_debian.yml
        playbooks/develop/ubuntu.yml
        vm/ansible/roles/wkhtmltopdf/defaults/main.yml
        vm/ansible/roles/wkhtmltopdf/tasks/main.yml
Please, commit your changes or stash them before you can merge.
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 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

So whats next …

Hi @Pirated

In my environment, I use the following sequence:

cd /home/frappe/.bench

git commit -a
git pull

cd /home/frappe/frappe-bench/apps/frappe

git commit -a
git pull

cd /home/frappe/frappe-bench/apps/erpnext

git commit -a
git pull

cd /home/frappe/frappe-bench

bench update

And with this, the update goes clean, without errors. Hope this helps.

If you are stuck then you can also reset you "git’ repo by using this command

git reset -hard
git pull

The above command is required to be executed in following directories:

/home/frappe/.bench

/home/frappe/frappe-bench/apps/frappe

/home/frappe/frappe-bench/apps/erpnext

Once this is done, you will be able to update as usual.

Then you are required to follow the explained procedure before running any update.

Hope this helps!


Regards
Saurabh

1 Like

@Pirated sorry was busy with family after sending you that message.

What @saurabh said is the correct solution. You need to update all the git repositories within the frappe directory.

Just a note:
I would avoid git reset -hard route. It will reset all your files to default, delete all attachments, etc. It is far safer to let git merge your changes.

As such, if you are on user frappe and using frappe-bench as the bench home directory, you can run this script

#!/bin/bash
cd /home/frappe/.bench
git commit -a -m "my changes"
cd /home/frappe/frappe-bench/apps/frappe
git commit -a -m "my changes"
cd /home/frappe/frappe-bench/apps/erpnext
git commit -a -m "my changes"
cd /home/frappe/frappe-bench
bench update

Hope this helps.

1 Like

ok moving to the next stage … @saurabh thanks for the detailed post

i have done all the steps you mention everything went smooth with no error … but bench update give the following error also tried the bench update --upgrade

/frappe/frappe-bench# bench update --upgrade
INFO:bench.utils:updating bench
Already up-to-date.
error: cannot open .git/FETCH_HEAD: Permission denied

error: cannot open .git/FETCH_HEAD: Permission denied

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.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
INFO:bench.app:pulling frappe
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 60, in update
    _update(pull, patch, build, bench, auto, restart_supervisor, requirements, no_backup, upgrade, force=force)
  File "/home/frappe/.bench/bench/commands/update.py", line 76, in _update
    pull_all_apps(bench_path=bench_path)
  File "/home/frappe/.bench/bench/app.py", line 140, 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 

Like I said earlier, if you are stuck you need to do this-

Go to the following directories, one by one:

/home/frappe/.bench
/home/frappe/frappe-bench/apps/frappe
/home/frappe/frappe-bench/apps/erpnext

and execute following commands:

git reset --hard
git pull

Once you are through all directories (one by one), then you can try to bench update command from /home/frappe/frappe-bench directory

Hope this helps!

1 Like

done as you said … git pull said on each folder you mention says already up to date…and the same error

home/frappe/frappe-bench# bench update
INFO:bench.utils:updating bench
Already up-to-date.
error: cannot open .git/FETCH_HEAD: Permission denied

error: cannot open .git/FETCH_HEAD: Permission denied

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.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
INFO:bench.app:pulling frappe
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 60, in update
    _update(pull, patch, build, bench, auto, restart_supervisor, requirements, no_backup, upgrade, force=force)
  File "/home/frappe/.bench/bench/commands/update.py", line 76, in _update
    pull_all_apps(bench_path=bench_path)
  File "/home/frappe/.bench/bench/app.py", line 140, 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

Hi @Pirated,

Seems you are having a permissions issue on the .git folders. Maybe you initially did the install as root or sudo?

You chould try changing permissions of the git folders. Try the following as root:

#!/bin/bash
chown -R frappe:frappe /home/frappe/.bench
chown -R frappe:frappe /home/frappe/frappe-bench/apps/frappe
chown -R frappe:frappe /home/frappe/frappe-bench/apps/erpnext
cd /home/frappe/frappe-bench
bench update
1 Like

Aftere Updating i’ve facing this issue (see image)

Please tell, how can i troubleshoot this…

thanks for beings so helpful @alimalkhalifa @saurabh
the permissions solved the last step to upgrade … update done successfully