Missing apps in directory

@rohit_w @nabinhait
Hello Team

Please i had a working instance working perfectly, then i was trying to install an app which failed with few errors. After trying to resolve the issue. i then observed my app directory is empty… Frappe erpnext and other sucessful installed app directories were all gone.

Will appreciate any help at the moment as its a live instance

Hi @EnSeal,

this might help

$ cd /home/frappe/frappe-bench/apps
$ git clone https://github.com/frappe/frappe.git
$ git clone https://github.com/frappe/erpnext.git

This should bring back the folders

Thank you @lasalesi

The files are back back i seem not to be able to make the sites launched. How do i fix all this and still maintain my sqldatabase

/frappe-bench$ bench update --reset
INFO:bench.utils:updating bench
INFO:bench.utils:git pull
error: cannot open .git/FETCH_HEAD: Permission denied

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 34, in update
update_bench()
File “/home/frappe/.bench/bench/utils.py”, line 254, in update_bench
exec_cmd(“git pull”, cwd=cwd)
File “/home/frappe/.bench/bench/utils.py”, line 153, in exec_cmd
raise CommandFailedError(cmd)
bench.utils.CommandFailedError: git pull

Hi @EnSeal,

you are welcome :wink: The above error comes from a permission issue, where frappe is not the owner of /home/frappe/.bench/.git/FETCH_HEAD

Try this

$ cd /home/frappe
$ sudo chown -R frappe:frappe *
$ cd .bench/.git
$ sudo chown -R frappe:frappe *

Then run update again. I assume from your comment that you have a productive installation. What is the status that you get on

$ bench restart

The installation was running all fine for months now with no issue…just until this morning i was trying to install another apps

I seem to be getting error on bench restart

/frappe-bench$ bench restart
INFO:bench.utils:sudo supervisorctl restart frappe-bench-workers: frappe-bench-web:
frappe-bench-web:frappe-bench-node-socketio: stopped
frappe-bench-workers:frappe-bench-frappe-short-worker-0: ERROR (spawn error)
frappe-bench-workers:frappe-bench-frappe-schedule: ERROR (spawn error)
frappe-bench-workers:frappe-bench-frappe-default-worker-0: ERROR (spawn error)
frappe-bench-workers:frappe-bench-frappe-long-worker-0: ERROR (spawn error)
frappe-bench-web:frappe-bench-frappe-web: ERROR (spawn error)
frappe-bench-web:frappe-bench-node-socketio: started

Seems like your supervisor has an issue. Have you tried rebooting the machine? Does it persist after a reboot? Is the ERP system showing “Sorry, we will be back soon”?

i really need to be sure my installation and database is intact. How can i tell these are fine and how do i bring the sites back online. I have checked mysql database and my sites database still looks intact…

How do i build back this instance with losing data

I really will appreciate your help.

Thanks

i have restarted and still same issues…Yes the sites are showing Sorry , we will be back soon

Hello @lasalesi

I am still getting a permission issue

Traceback (most recent call last):
File “/usr/local/bin/bench”, line 11, in
load_entry_point(‘bench’, ‘console_scripts’, ‘bench’)()
File “/home/ubuntu/frappe-bench/src/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 1063, in invoke
Command.invoke(self, 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/ubuntu/frappe-bench/src/frappe-bench/bench/commands/init.py”, line 31, in bench_command
setup_logging(bench_path=bench_path)
File “/home/ubuntu/frappe-bench/src/frappe-bench/bench/utils.py”, line 293, in setup_logging
hdlr = logging.FileHandler(log_file)
File “/usr/lib/python2.7/logging/init.py”, line 913, in init
StreamHandler.init(self, self._open())
File “/usr/lib/python2.7/logging/init.py”, line 943, in _open
stream = open(self.baseFilename, self.mode)
IOError: [Errno 13] Permission denied: ‘/home/frappe/.bench/.git/logs/bench.log’

This is a new file now…

$ cd /home/frappe/.bench/.git
$ sudo chown -R frappe:frappe *

this is a hidden folder, therefore, the chown -R might have skipped it. Use

$ ls -l

to check ownership. frappe will require all files to be owned by it.

Resul of ls -l below

total 64
drwxr-xr-x 2 frappe frappe 4096 Apr 18 10:16 branches
-rw-r–r-- 1 frappe frappe 266 Apr 18 10:16 config
-rw-r–r-- 1 frappe frappe 73 Apr 18 10:16 description
-rw-r–r-- 1 frappe frappe 23 Apr 18 10:16 HEAD
drwxr-xr-x 2 frappe frappe 4096 Apr 18 10:16 hooks
-rw-r–r-- 1 frappe frappe 18517 Apr 18 10:16 index
drwxr-xr-x 2 frappe frappe 4096 Apr 18 10:16 info
drwxr-xr-x 3 frappe frappe 4096 Apr 18 10:16 logs
drwxr-xr-x 4 frappe frappe 4096 Apr 18 10:16 objects
-rw-r–r-- 1 frappe frappe 107 Apr 18 10:16 packed-refs
drwxr-xr-x 5 frappe frappe 4096 Apr 18 10:16 refs
-rw-r–r-- 1 frappe frappe 41 Apr 18 10:16 shallow

Error still persist

INFO:bench.utils:updating bench
INFO:bench.utils:git pull
error: cannot open .git/FETCH_HEAD: Permission denied

Traceback (most recent call last):
File “/usr/local/bin/bench”, line 11, in
load_entry_point(‘bench’, ‘console_scripts’, ‘bench’)()
File “/home/ubuntu/frappe-bench/src/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/ubuntu/frappe-bench/src/frappe-bench/bench/commands/update.py”, line 34, in update
update_bench()
File “/home/ubuntu/frappe-bench/src/frappe-bench/bench/utils.py”, line 254, in update_bench
exec_cmd(“git pull”, cwd=cwd)
File “/home/ubuntu/frappe-bench/src/frappe-bench/bench/utils.py”, line 153, in exec_cmd
raise CommandFailedError(cmd)
bench.utils.CommandFailedError: git pull

Try this:

$ cd /home/frappe/.bench
$ sudo git pull
$ sudo chown -R frappe:frappe *
$ cd /home/frappe/frappe-bench
$ bench update

Hi @lasalesi

I am still having same error message…Any other tip ?

Was git pull in .bench successful? Can you check the owner of .bench/.git/FETCH_HEAD using ls -la?

yes it was successful…the owner is root .

drwxr-xr-x 8 frappe frappe 4096 Apr 18 13:57 .
drwxr-xr-x 9 frappe frappe 4096 Apr 18 10:16 …
drwxr-xr-x 2 frappe frappe 4096 Apr 18 10:16 branches
-rw-r–r-- 1 frappe frappe 266 Apr 18 10:16 config
-rw-r–r-- 1 frappe frappe 73 Apr 18 10:16 description
-rw-r–r-- 1 root root 93 Apr 18 13:57 FETCH_HEAD
-rw-r–r-- 1 frappe frappe 23 Apr 18 10:16 HEAD
drwxr-xr-x 2 frappe frappe 4096 Apr 18 10:16 hooks
-rw-r–r-- 1 frappe frappe 18517 Apr 18 10:16 index
drwxr-xr-x 2 frappe frappe 4096 Apr 18 10:16 info
drwxr-xr-x 3 frappe frappe 4096 Apr 18 10:16 logs
drwxr-xr-x 4 frappe frappe 4096 Apr 18 10:16 objects
-rw-r–r-- 1 root root 41 Apr 18 13:57 ORIG_HEAD
-rw-r–r-- 1 frappe frappe 107 Apr 18 10:16 packed-refs
drwxr-xr-x 5 frappe frappe 4096 Apr 18 10:16 refs
-rw-r–r-- 1 frappe frappe 41 Apr 18 10:16 shallow

also note my default user where my have my existing sites is the ‘ubuntu’ user i need to be able to give all permission to this user

You should change the owner of FETCH_HEAD to frappe, then it will work…

Thanks @lasalesi

See new error message below

INFO:bench.utils:updating bench
INFO:bench.utils:git pull
Already up-to-date.
fatal: ‘upstream’ does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 11, in
load_entry_point(‘bench’, ‘console_scripts’, ‘bench’)()
File “/home/ubuntu/frappe-bench/src/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/ubuntu/frappe-bench/src/frappe-bench/bench/commands/update.py”, line 49, in update
version_upgrade = is_version_upgrade()
File “/home/ubuntu/frappe-bench/src/frappe-bench/bench/app.py”, line 249, in is_version_upgrade
raise InvalidBranchException(“Specified branch of app {0} is not in upstream”.format(app))
bench.app.InvalidBranchException: Specified branch of app frappe is not in upstream

What do you see when running git status and git remote -v in /home/frappe/.bench?

On branch master
Your branch is up-to-date with ‘origin/master’.
nothing to commit, working directory clean

ubuntu@ip-172-31-53-7:~/.bench$ git remote -v
origin GitHub - frappe/bench: CLI to manage Multi-tenant deployments for Frappe apps (fetch)
origin GitHub - frappe/bench: CLI to manage Multi-tenant deployments for Frappe apps (push)