Commit vs. Stash

I waited for a the “Default Customer” issue to be fixed in the POS module and now I want to update my production installation to the new 8.0.22 in order to take advantage of the fix. I logged into the server via SSH and ran the following:

sudo -i
cd /home/frappe/frappe-bech
bench update

And I got several errors indicating that there had been changes made to nginx.py. The only changes made to any py scripts would have to have been done during the install.py script running. No other work has been done at the console.

The error is also telling me I need to be commit the changes or stash them before the merge can take place. It follows with a series of abort comments. So how would I “commit” changes that were done by the install.py script? I certainly do not want anything to change because the system works like it should. Does “commit” keep everything the same as it is now? if so, how do I tell the system to commit?

Here is the short trace back I got when trying to run update:

root@MSD-ERP:/home/frappe/frappe-bench# bench update
INFO:bench.utils:updating bench
INFO:bench.utils:git pull
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 6 (delta 4), reused 3 (delta 1), pack-reused 0
Unpacking objects: 100% (6/6), done.
From GitHub - frappe/bench: CLI to manage Multi-tenant deployments for Frappe apps
080ca17…e3fa8c4 master → origin/master
Updating 080ca17…e3fa8c4
error: Your local changes to the following files would be overwritten by merge:
bench/config/nginx.py
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
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 722, in ca ll
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1066, in inv oke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 895, in invo ke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 535, in invo ke
return callback(*args, **kwargs)
File “/home/frappe/.bench/bench/commands/update.py”, line 35, in update
update_bench()
File “/home/frappe/.bench/bench/utils.py”, line 229, in update_bench
exec_cmd(“git pull”, cwd=cwd)
File “/home/frappe/.bench/bench/utils.py”, line 130, in exec_cmd
raise CommandFailedError(cmd)
bench.utils.CommandFailedError: git pull
root@MSD-ERP:/home/frappe/frappe-bench#

What is the difference between commit and stash? Which should I use in this instance? How do I execute either in order to get the bench update to work?

If you can point me to documentation that would explain this it would be most helpful.

Thank you,

BKM

I would suggest stashing the changes. You can always bring them back if needed, but if it’s saying there’s a conflict then it’s because it’s trying to update the file to something newer.

Running git stash in the bench folder should do it.

When I run

git stash

I get the following error:

root@MSD-ERP:/home/frappe/frappe-bench# git stash
fatal: Not a git repository (or any of the parent directories): .git
root@MSD-ERP:/home/frappe/frappe-bench# root@MSD-ERP:/home/frappe/frappe-bench# git stash
-bash: root@MSD-ERP:/home/frappe/frappe-bench#: No such file or directory
root@MSD-ERP:/home/frappe/frappe-bench# fatal: Not a git repository (or any of the parent directories): .git
-bash: syntax error near unexpected token `(’
root@MSD-ERP:/home/frappe/frappe-bench# root@MSD-ERP:/home/frappe/frappe-bench#
-bash: root@MSD-ERP:/home/frappe/frappe-bench#: No such file or directory

Is there a special syntax to “git” that I need to make this work?

BKM

You need to be in the home/frappe/bench-repo/bench folder

Ok. I figured out that I was in the wrong directory to run the “git Stash” command. I remedied that situation. I ran git stash from the /home/frappe/.bench directory and it was successful. I then went back to the /home/frappe/frappe-bench directory and ran the bench update command. This is what I got:


root@MSD-ERP:/home/frappe/frappe-bench# bench update
INFO:bench.utils:updating bench
INFO:bench.utils:git pull
Updating 080ca17…e3fa8c4
Fast-forward
bench/config/nginx.py | 2 ±
1 file changed, 1 insertion(+), 1 deletion(-)
remote: Counting objects: 1008, done.
remote: Compressing objects: 100% (65/65), done.
remote: Total 1008 (delta 712), reused 701 (delta 686), pack-reused 257
Receiving objects: 100% (1008/1008), 227.30 KiB | 0 bytes/s, done.
Resolving deltas: 100% (811/811), completed with 247 local objects.
From GitHub - frappe/frappe: Low code web framework for real world applications, in Python and Javascript
6f5817d…36abbb6 master → upstream/master

  • [new branch] beta-version-naming → upstream/beta-version-naming
    6f5817d…eb079e1 develop → upstream/develop
  • [new branch] revert-2780-image-in-data-import → upstream/revert-2780-image-in-data-import
  • [new tag] v8.0.36 → v8.0.36
  • [new tag] v8.0.21 → v8.0.21
  • [new tag] v8.0.22 → v8.0.22
  • [new tag] v8.0.23 → v8.0.23
  • [new tag] v8.0.24 → v8.0.24
  • [new tag] v8.0.25 → v8.0.25
  • [new tag] v8.0.26 → v8.0.26
  • [new tag] v8.0.27 → v8.0.27
  • [new tag] v8.0.28 → v8.0.28
  • [new tag] v8.0.29 → v8.0.29
  • [new tag] v8.0.30 → v8.0.30
  • [new tag] v8.0.31 → v8.0.31
  • [new tag] v8.0.32 → v8.0.32
  • [new tag] v8.0.33 → v8.0.33
  • [new tag] v8.0.34 → v8.0.34
  • [new tag] v8.0.35 → v8.0.35
    INFO:bench.utils:./env/bin/pip install Pillow
    Requirement already satisfied: Pillow in ./env/lib/python2.7/site-packages
    Requirement already satisfied: olefile in ./env/lib/python2.7/site-packages (from Pillow)

Cannot proceed with update: You have local changes in app “frappe” that are not committed.

Here are your choices:

  1. Merge the frappe app manually with “git pull” / “git pull --rebase” and fix conflicts.
  2. Temporarily remove your changes with “git stash” or discard them completely
    with “bench update --reset” or for individual repositries “git reset --hard”
  3. If your changes are helpful for others, send in a pull request via GitHub and
    wait for them to be merged in the core.
    root@MSD-ERP:/home/frappe/frappe-bench#

So it appears there are still changes the git stash command did not fix, because I still got a warning that it “Cannot proceed with update: You have changes in app “frappe” that are not committed.”

I am not sure what to make of this. What changes might it be referencing? The data I imported to the system? The configuration of the users? What does it want to be committed and how do I go about that? I have not done anything except install the system, import data and setup users. Today I did the update in order to get the POS changes. So I am not sure what needs to be committed.

BKM

@Ben_Cornwell_Mott

There does not appear to be such a folder as “/home/frappe/bench-repo/bench”
I went to “/home/frappe/.bench” to run the git stash command and it appeared to work.

Here is a directory list of /home/frappe:

root@MSD-ERP:/home/frappe# ls -la
total 44
drwxr-xr-x 7 frappe frappe 4096 Apr 22 11:54 .
drwxr-xr-x 4 root root 4096 Apr 22 11:39 …
-rwxr-xr-x 1 frappe frappe 220 Nov 5 2016 .bash_logout
-rwxr-xr-x 1 frappe frappe 3515 Nov 5 2016 .bashrc
drwxr-xr-x 8 frappe frappe 4096 May 8 17:54 .bench
drwxr-xr-x 3 frappe frappe 4096 Apr 22 11:49 .cache
drwxr-xr-x 8 frappe frappe 4096 Apr 22 11:53 frappe-bench
-rwxr-xr-x 1 frappe frappe 145 Apr 22 11:54 .inputrc
drwxr-xr-x 99 frappe frappe 4096 Apr 22 11:52 .npm
-rwxr-xr-x 1 frappe frappe 675 Nov 5 2016 .profile
drwxr-xr-x 2 frappe frappe 4096 Apr 22 11:39 .ssh
root@MSD-ERP:/home/frappe#

Are you possibly referencing an older version?

I am still not sure why I cannot get the bench update to work.

BKM

Got the same error messages and didn’t change anything! Trying to update from ERPNext v7.2.19 (Frappe v7.2.15)

Why is this happening?

Kind regards,

Can you post the full trace?

The git stash command did work… you’re now facing the same issue with a different repository.
This time, it’s the frappe repo. If you go to frappe-bench/apps/frappe and run git stash, that should work. You may also need to run it in frappe-bench/apps/erpnext if you get a similar error for the erpnext repository.

1 Like

Hi @Ben_Cornwell_Mott

Pls find below

frappe@ip-172-31-16-200:~/frappe-bench$ bench update
INFO:bench.utils:updating bench
Updating ae17b6b..e3fa8c4
error: Your local changes to the following files would be overwritten by merge:
        bench/commands/config.py
        bench/commands/git.py
        bench/commands/utils.py
        bench/config/common_site_config.py
        bench/config/nginx.py
        bench/config/redis.py
        bench/config/site_config.py
        bench/tests/test_setup_production.py
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 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/.bench/bench/commands/update.py", line 35, 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

Kind regards,

@wale, did you make any changes to the bench repo? You can run a git diff to check. Most likely they should only be some permission-related changes if you haven’t manually made any. I had a similar issue and I ran git reset --hard in the bench repo folder to get rid of the changes and then proceeded with the update. Proceed with caution, however.

That is the correct folder for the bench repo

Hi @ishanloya

Thanks for your input. Didn’t make any changes! I already reset my git repositories and finished the update. I’m just wondering why this is happening at all

Thanks

You can make git ignore permission changes

@Ben_Cornwell_Mott

Thanks Ben. That did seem to get the files in order, but I now run into permission issues. It now tells me that I have insufficient permissions for adding object to repository database .git/objects
I used SUDO to run this with root permissions, but it didn’t seem to matter. This is what the trace looked like:


jmi@MSD-ERP:~$ sudo -i
root@MSD-ERP:~# cd /home/frappe/frappe-bench
root@MSD-ERP:/home/frappe/frappe-bench# bench update
INFO:bench.utils:updating bench
INFO:bench.utils:git pull
Already up-to-date.
remote: Counting objects: 33, done.
remote: Compressing objects: 100% (33/33), done.
remote: Total 33 (delta 12), reused 1 (delta 0), pack-reused 0
error: insufficient permission for adding an object to repository database .git/objects
fatal: failed to write object
fatal: unpack-objects failed
remote: Counting objects: 33, done.
remote: Compressing objects: 100% (33/33), done.
remote: Total 33 (delta 12), reused 1 (delta 0), pack-reused 0
error: insufficient permission for adding an object to repository database .git/objects
fatal: failed to write object
fatal: unpack-objects failed
INFO:bench.utils:./env/bin/pip install Pillow
Requirement already satisfied: Pillow in ./env/lib/python2.7/site-packages
Requirement already satisfied: olefile in ./env/lib/python2.7/site-packages (from Pillow)
INFO:bench.app:pulling frappe
INFO:bench.utils:git pull upstream master
remote: Counting objects: 31, done.
remote: Compressing objects: 100% (31/31), done.
remote: Total 31 (delta 12), reused 0 (delta 0), pack-reused 0
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 “/usr/local/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/local/lib/python2.7/dist-packages/click/core.py”, line 722, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 535, 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 170, 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 130, in exec_cmd
raise CommandFailedError(cmd)
bench.utils.CommandFailedError: git pull upstream master
root@MSD-ERP:/home/frappe/frappe-bench#


Any idea how the directories were configured to be resistant to root permissions? How can I change the .git/objects repo so the bench update can add things to the repo?

BKM

it looks like the user name that has installed ERPNext is frappe (looking at your home/frappe folder structure). If I’m not mistaken, you need to be logged in as that user in order to modify / update ERPNext. Using sudo won’t allow you to do it - you can’t be the root user.

Yes its very easy to run bench update as another user or root. This will really screw things up.

Luckily its easy to fix.

as root

cd /home/frappe

chown -R frappe: frappe-bench

This will reset ownership to frappe throughout each file and folder if bench update has been run be another user. All files in a user’s dir are normally only owned by that user otherwise user frappe cannot make changes.

Hope this helps … i’ve run bench update as root by mistake :wink:
Julian

@Ben_Cornwell_Mott
@Julian_Robbins

Thank you for the input on the user issue. Unfortunetely, there is no “frappe” user. Only a frappe directory in the /home directory. The system was originally installed on a fresh Debian box with nothing but the basics and only the root user and a single user called “jmi”. I used the jmi user with “sudo” to run the install.py script to install the entire system. I did NOT use the switch to have a user created during the process. Install.py still lives in the /home/jmi directory.

Without a real frappe user, I am not sure how I would actually gain control of the files. I will try Julian’s suggestion of reassigning ownership and see if that works. However, I believe there is an inherent flaw in the install.py script. I was expecting everything to install in the jmi directory because I did not use the --user switch when I ran the install. Finding the /home/frappe directory really confused me because I had no idea how to properly access everything. That is why I have been using the root user to do it all. A frappe user was never created, just the directory.

I really didn’t want a frappe user because it is so common that everyone would know what to look for if they wish to do harm. That was the reason I used jmi user to do the install. At this point I do not know how to make this right.

BKM

Hi

I take your point about the commonality of a frappe user but surely it’s
much less safe to run everything as root instead ?

It may be as easy to backup your site and reinstall with frappe user
perhaps …

Julian

@Julian_Robbins

I am beginning to think that is the best route. I just have so much time invested in getting the system this far and importing tens of thousands of records through a klunky import tool that can only handle 500-700 records at a time, I hate to have to start over again. However, it appears that the install.py script is only happy with a frappe user in the linux OS, and anything else has created much havoc for me.

I will still try changing the ownership of the directory structure to my “jmi” user, but if that doesn’t work, then I will be stripping the server and starting over again. I will just have to set a very strong password for the frappe user.
Thanks for your assistance. I am grateful for the help.

BKM