When I run sudo bench setup production, I get the error “sudo: bench: command not found”. Without sudo, the bench command works correctly.
erpnext@ubuntu-s-1vcpu-2gb-amd-blr1-01:~/erpnext$ bench setup production
WARN: superuser privileges required for this command
erpnext@ubuntu-s-1vcpu-2gb-amd-blr1-01:~/erpnext$ sudo bench setup production
sudo: bench: command not found
erpnext@ubuntu-s-1vcpu-2gb-amd-blr1-01:~/erpnext$ which bench
/home/erpnext/.local/bin/bench
erpnext@ubuntu-s-1vcpu-2gb-amd-blr1-01:~/erpnext$ sudo /home/erpnext/.local/bin/bench setup production
Traceback (most recent call last):
File "/home/erpnext/.local/bin/bench", line 5, in <module>
from bench.cli import cli
ModuleNotFoundError: No module named 'bench'
erpnext@ubuntu-s-1vcpu-2gb-amd-blr1-01:~/erpnext$
The bench commend only works on your frappe-bench installed directory. By default, the folder name will be frappe-bench. So, try to find that folder, get into it, and run all your bench commends.
I used the following command to create the frappe-bench
bench init --frappe-branch version-13 erpnext
Since erpnext is specified at the end of the command, it created folder “erpnext”, I am inside this folder, and bench command works properly, the only problem is when running with the sudo command.
See “bench --site all list-apps” works properly.
erpnext@ubuntu-s-1vcpu-2gb-amd-blr1-01:~/erpnext$ bench --site all list-apps
frappe
erpnext
erpnext@ubuntu-s-1vcpu-2gb-amd-blr1-01:~/erpnext$