Bench update showing error

Hi Experts ,

I am getting this error , while updating bench . Please help

From https://github.com/frappe/erpnext
 * branch            develop    -> FETCH_HEAD
   465b753..12e8277  develop    -> upstream/develop
Updating 465b753..12e8277
error: Your local changes to the following files would be overwritten by merge:
	erpnext/selling/doctype/quotation/quotation.json
	erpnext/stock/doctype/item/item.json
Please, commit your changes or stash them before you can merge.
Aborting
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 9, in <module>
    load_entry_point('bench==3.0.0', 'console_scripts', 'bench')()
  File "/home/ommi/bench-repo/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/ommi/bench-repo/bench/commands/update.py", line 60, in update
    _update(pull, patch, build, bench, auto, restart_supervisor, requirements, no_backup, upgrade, force=force)
  File "/home/ommi/bench-repo/bench/commands/update.py", line 76, in _update
    pull_all_apps(bench_path=bench_path)
  File "/home/ommi/bench-repo/bench/app.py", line 121, in pull_all_apps
    remote=remote, branch=get_current_branch(app, bench_path=bench_path)), cwd=app_dir)
  File "/home/ommi/bench-repo/bench/utils.py", line 88, in exec_cmd
    raise CommandFailedError(cmd)
bench.utils.CommandFailedError: git pull  upstream develop
ommi@ommi:~/frappe-bench$ 

Thanks in advance

1 Like

git commit to keep you changes in your local or git stash to discard your changes…then do bench update again. It’s highly recommended to do customization in your own custom app, otherwise update is always broken… because frappe/erpnext is heavily updated

1 Like

Hi @jof2jc , many thanks for responding . I want my customization to be there , so if I use git commit , will the two modules being displayed here will get updated as well or will these two modules be ignored ?

Thanks in advance

1 Like

They will get updated too but sometimes you’ll need to resolve conflicts that occur between your changes and the updates

1 Like

Thank you so much for your swift response . Will any of my custom script or custom doc get deleted in the process ?

1 Like

Short answer…No!

1 Like

By custom, do you mean you created them with the ‘custom’ checkbox? Or that you made them yourself in developer mode?

If you have custom scripts and custom docs it’s really easy to move them into a custom app! I highly recommend doing this now rather than later, because the technical debt of having to resolve merge conflicts grows really quickly. A little work now to save a huge headache later.

1 Like

@jof2jc @alec_ruizramon1

Thanks a ton for responding , by custom doc I mean those docs which I created in developer mode . All my custom docs are in my custom app , no worries about that , only I customized the item doc to my requirement . Shall I proceed running bench update after using git commit command ?

1 Like

Yes, but be prepared for merge conflicts. You’ll have to go in and manually resolve the changes when they arise.

If you changed server-side code, consider using hooks instead, and if you changed JS, consider moving it into the custom app as well.

1 Like

@alec_ruizramon1 . Thank you so much for swift response sir , My concern is I could not move the item (standard) doc into my custom app , if I do that I should move that back to its place after completing bench update by doing so I will miss the update released for this doc , also I am scared of moving a standard doc to some location

1 Like

I’m sorry, I must not have been clear!

The idea is that you move only the ‘custom’ parts, i.e. the parts that you changed about Item, into the custom app. The rest of the Item doc stays where it is, but unchanged, and the custom parts are ‘hooked’ into Item from the custom app.

If you give me an idea of what you changed, I can provide some more help.

1 Like

@alec_ruizramon1 . Many thanks for swift response and taking time to guide me sir . Actually I customized item doc for a forging industry . An item ( steel ) will have 18 elements (attributes) , like how we define a item by its color , size and shape , a steel will have 18 elements ( chemical composition ) , so I have added fields which define its chemical composition. I have added 108 fields totally that’s why I am worried. Please guide me . Also could I copy the json code of the custom fields I created and add it after update ?

Please help

Thanks in advance

1 Like

If the fields were created as custom fields, you should be fine! (As in, you did not navigate to DocType → Item and add from there).

In your console, go into apps/erpnext and run git status and paste here - it shows the files that have changed.

1 Like

Thanks again for quick response sir , please guide me

ommi@ommi:~$ cd /home/ommi/frappe-bench/apps/erpnext/erpnext
ommi@ommi:~/frappe-bench/apps/erpnext/erpnext$ git status
On branch develop
Your branch is behind 'upstream/develop' by 114 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   buying/doctype/supplier/supplier.json
	modified:   crm/doctype/lead/lead.json
	modified:   manufacturing/doctype/bom/bom.json
	modified:   selling/doctype/customer/customer.json
	modified:   selling/doctype/quotation/quotation.json
	modified:   stock/doctype/item/item.json
	modified:   stock/doctype/stock_entry/stock_entry.json

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	buying/doctype/grade/
	selling/doctype/quotationmaster/
	stock/doctype/brand/

no changes added to commit (use "git add" and/or "git commit -a")
ommi@ommi:~/frappe-bench/apps/erpnext/erpnext$
1 Like

Ok -

It looks like you created some docs → Grade, Quotationmaster. It’s interesting that Brand is untracked - that doc should exist in Setup. Have you been using the Brand doc in Stock instead of the one that is provided with ERPNext?

Also, if you run git diff, it will show you changes in the code. In the JSON files that are changed, are there fields added, or is it simply a few things like when it was last modified?

1 Like

@alec_ruizramon1 Thanks for responding sir , I tried deleting this untracked docs , but still it is showing ,I am not worried about all these docs Sir , only the item doc , why because I have added around 90 fields . What shall I do now ?

Please guide me

1 Like

If you run git diff, what does it show for the …/item.json file? I want to make sure that the fields were not added in the Item doctype. If you added them as Custom Field or through Customize Form it should be okay.

You also can do this…
git add .
git stash
…run update, go back to erpnext folder
git stash apply

1 Like

Sir , running git diff does not show anything for the item.json , only it shows a field that I added to the supplier module . I directly opened the item doc and added fields that I want . Please guide me

1 Like

Interesting, it should show something since git tracks it as modified.

In that case, run the commands above (git add . , git stash, go do the update, back to erpnext & git stash apply)

1 Like

Thanks a lot sir . I will follow the commands you provided and update you when done .

Thank you

2 Likes