Setup production problem - superuser privileges required

sudo python --production --user user

user@erp:~/frappe-bench$ sudo bench setup production --user user
sudo: bench: command not found

See post edited above. sorry was giving you wrong commands.

No problem.

sudo bench setup production user

This means the command ‘bench’ is not in that list of directories identified by $PATH.

When you sudo, you get a preconfigured $PATH, which is (supposed to be) something like the root user’s default path. Your program is not in that list of directories identified by $PATH.

For more info and what to do path - Why running command as sudo returns command not found? - Unix & Linux Stack Exchange

I have exactly same problem. No chance. If command not found yeah it may not be in path . But neither giving full path nor defining enviroment variable under root worked.
What about python aliases? As i am not linux expert i clearly don’t understand which python verison exactly we should use. It seems to me both pyton2 and python3 are used

Well, in any case there’s no note or emphasis here to never use (nor have to use ie precede) the bench command with sudo.

But if you have no choice and must use sudo - say to skip over a permission denied violation - then in the install likely you introduced a file ownership issue (that can easily be fixed with chown).

I am not sure what the original poster’s problem was, as Linux distros differ in ‘subtle opinionated’ ways for eg use visudo to specify sudo privileges

ERPNext uses virtualenv to maintain its own Python toolchain environment (separate from the host OS that typically uses a Python version too), and starting with version 12 moved to 3.5+ from 2.7

ok just to clarify to avoid confusion - sudo is required this one time only in the easy install case (necessary to create the actual bench):

sudo bench setup production

Here’s the reference Setup Production

I hope this helps

Well. Everything what i am trying to do is standard ERP next installation on fresh installed centos 8 . Also there is no special case ,restriction etc

bench setup nginx
command working well under erp user. But supervisor command not working.
I had tried ;
bench setup supervisor
with full path ( ./bla bla/bench )
with sudo ( sudo bench setup supervisor)
with root ( # bench setup supervisor)
with/without root enviroment variables (su erp/su - erp && bench setup supervisor )

Problem seems something related with supervisor.

I am following this guide ( just like standard manual installation guide but more clear )

I had passed all of the step and erpnetx working on dev mode. But when i try to install production mode i hit to wall.

Perhaps turn off selinux if you have not already tried that?

A forum search will turn up pointers - BKM and others have posted their install notes for CentOS.

Also check the logs for clues - for eg /home/frappe/frappe-bench/logs and /var/log

Did you find the solution. I still get the error “superuser privileges required for this command” , can you help???

When you did the git clone approximately here…

cd ~
git clone bench-repo;
sudo pip3 install frappe-bench;     #NB!!! MUST be sudo'd!!! 
#if you exclude the sudo part, then the sudo bench commands required later (for production mode) will fail!
1 Like

sudo pip3 install frappe-bench;
Bench commands replies “command not found” ( with sudo or without )

sudo bench init frappe-bench --frappe-branch version-12
sudo: bench: command not found

sudo bench init frappe-bench --frappe-branch version-12
sudo: bench: command not found

How did you resolve that ??

This had to be done at install time

Is this really standard procedure in setting up production?
Because I don’t think I ever see to use sudo on any documentation (or maybe I’m just not looking enough)

Now, if the repo had been installed (convert from dev) what should we do?

If you check the scripts here for debian or here for ubuntu - there is a point in the installation where you MUST use sudo, otherwise you cannot set up supervisor (required for production) correctly

But after install with sudo, the bench command is not found. I also read many are having the same issue.

OK… let me read and redo as that note first.

Hi @trentmu,

I had read the note and see that the reason for sudo for pip3 install frappe-bench is to run sudo bench command later on the process (in setting up production).
But I didn’t see why then the bench command is not found when doing bench init... (the next process)

If setting up for development, without sudo is fine. Bench can init and start. Site can be accessed. So the process is stop without having to go further to bench setup supervisor and so on…

And using pip3 install frappe-bench doesn’t need to git clone the bench -repo.

If want to use bench-repo the command used is pip3 install -e bench-repo