Cannot change Default Site using bench command

I created a new site, using the standard command:

bench new-site briantest.local

Next, I added the app ERPNext:

bench --site briantest.local install-app erpnext

All success. No errors. Next, I want to make this my default site. The “bench” tool offers this feature, so I tried it:

bench set-default-site briantest.local

This produced the following error message:

frappe app is not installed.
Run the following command to install frappe
bench get-app GitHub - frappe/frappe: Low code web framework for real world applications, in Python and Javascript
/bin/sh: 1: /home/brian/frappe-bench/env/bin/frappe: not found

[details=Summary]frappe app is not installed.
Run the following command to install frappe
bench get-app GitHub - frappe/frappe: Low code web framework for real world applications, in Python and Javascript
/bin/sh: 1: /home/brian/frappe-bench/env/bin/frappe: not found
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 9, in
load_entry_point(‘bench==4.1.0’, ‘console_scripts’, ‘bench’)()
File “/home/brian/bench-repo/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/brian/bench-repo/bench/commands/utils.py”, line 71, in set_default_site
set_default_site(site)
File “/home/brian/bench-repo/bench/utils.py”, line 366, in set_default_site
cwd=os.path.join(bench_path, ‘sites’))
File “/home/brian/bench-repo/bench/utils.py”, line 129, in exec_cmd
raise CommandFailedError(cmd)
bench.utils.CommandFailedError: /home/brian/frappe-bench/env/bin/frappe --use briantest.local[/details]

To the best of my knowledge, Frappe is definitely installed. If you try to follow the error message’s instructions, and execute the command: bench get-app https://github.com/frappe/frappe.git

…it fails. Because Frappe is already installed. I dug further.

The error I’m seeing is triggered by the Python function get_frappe in this file:

/home/brian/bench-repo/bench/utils.py

And the reason it’s throwing the error: because it cannot find this path:

/home/brian/frappe-bench/env/bin/frappe

I checked, and that path is valid down to “bin”. But there is no file or folder within named “frappe”

So. One of 2 things has happened:
(Possibility 1) Bench is looking at a wrong path, or for a file/path that doesn’t exist. Why is it looking for this?

…or…

(Possibility 2) Bench is correct in looking there. But my Frappe installation missed something, and didn’t create files at /home/brian/frappe-bench/env/bin/frappe. If so, why?

I’ve seen a few other posts on the forum related to set-default-site. None had any resolution. I suspect people gave up, and edited the default site manually. I could do that too. But I want to resolve the issue with bench. Thoughts?

@brian_pond Try bench use briantest.local

1 Like

Thanks! That seems to have done the trick. I like it!

So, if that’s how it should be done. Then can we make the following changes?

  1. Add this command when examining options

bench ?

  1. And then remove the “set-default-site” if that command is deprecated and no longer working?

This way we don’t stump users in the future, and avoid more posts about this. :slight_smile:

1 Like

Can you please raise a github issue for removing this command set-default-site so that we remember to do this.

And also instead of bench ? use bench --help, it will give list of all the commands.

Done. :slight_smile: Created issue #361. Update Bench command line options · Issue #361 · frappe/bench · GitHub

Thanx!

To confirm no change with this issue, currently running this:

frappe@ubuntu1804lts:~/frappe-bench$ bench version
erpnext 12.4.0
frappe 12.2.0
frappe@ubuntu1804lts:~/frappe-bench$ bench --version
4.1.0

bench set-default-site X continues to raise a traceback whereas this undocumented bench use X works.

Thanks for this workaround!