Bench 4.1.0 does not seem to have new-site switch, how to create sites?

~/frappe $ bench --help
Usage:  [OPTIONS] COMMAND [ARGS]...

  Bench manager for Frappe

Options:
  --version
  --help     Show this message and exit.

Commands:
  backup                 backup site
  backup-all-sites       backup all sites
  config                 change bench configuration
  disable-production     Disables production environment for the bench.
  download-translations  Download latest translations
  exclude-app            Exclude app from updating
  get-app                clone an app from the internet and set it up in...
  include-app            Include app from updating
  init                   Create a New Bench Instance.
  install                Install system dependancies
  migrate-env            Migrate Virtual Environment to desired Python...
  new-app                start a new app
  prepare-beta-release   Prepare major beta release from develop branch
  release                Release app (internal to the Frappe team)
  remote-reset-url       Reset app remote url to frappe official
  remote-set-url         Set app remote url
  remote-urls            Show apps remote url
  remove-app             completely remove app from bench
  renew-lets-encrypt     Renew Let's Encrypt certificate
  restart                Restart supervisor processes or systemd units
  retry-upgrade
  set-default-site       Set default site for bench
  set-mariadb-host       Set MariaDB host for bench
  set-nginx-port         Set nginx port for site
  set-ssl-certificate    Set ssl certificate path for site
  set-ssl-key            Set ssl certificate private key path for site
  set-url-root           Set url root for site
  setup                  Setup bench
  shell
  src                    Prints bench source folder path, which can be used...
  start                  Start Frappe development processes
  switch-to-branch       Switch all apps to specified branch, or specify...
  switch-to-develop      Switch frappe and erpnext to develop branch
  switch-to-master       Switch frappe and erpnext to master branch
  update                 Update bench

[]
~/frappe $ bench --version
4.1.0

I am utterly confused. How do I make sites without the new-site switch?

Are you in your bench root directory? eg frappe-bench

Yes, ~/frappe means I’m in /home/user/frappe/ folder.

that may not be deep enough

what does ls in /home/user/frappe/ show?

I deleted the folder already, trying bench init frappe again to see if that helps. It’s the folder where I ran, successfully, bench install-app erpnext.

new-site was showing fine, but there was problem with numpy when I did bench new-site site1.local, which is why I ran bench update. After bench-update, new-site disappeared.

After making the new bench init, I’ve new-site again:

$ ls -al
total 36
drwxr-xr-x 7 pi pi 4096 Jan  4 20:32 .
drwxr-xr-x 9 pi pi 4096 Jan  4 18:34 ..
-rw-r--r-- 1 pi pi  429 Jan  4 20:32 Procfile
drwxr-xr-x 4 pi pi 4096 Jan  4 19:21 apps
drwxr-xr-x 3 pi pi 4096 Jan  4 20:32 config
drwxr-xr-x 7 pi pi 4096 Jan  4 19:19 env
drwxr-xr-x 2 pi pi 4096 Jan  4 18:34 logs
-rw-r--r-- 1 pi pi  194 Jan  4 20:32 patches.txt
drwxr-xr-x 3 pi pi 4096 Jan  4 20:22 sites
~/frappe $  bench --help
Usage:  [OPTIONS] COMMAND [ARGS]...

  Bench manager for Frappe

Options:
  --version
  --help     Show this message and exit.

Commands:
  backup                 backup site
  backup-all-sites       backup all sites
  config                 change bench configuration
  disable-production     Disables production environment for the bench.
  download-translations  Download latest translations
  exclude-app            Exclude app from updating
  get-app                clone an app from the internet and set it up in...
  include-app            Include app from updating
  init                   Create a New Bench Instance.
  install                Install system dependancies
  migrate-env            Migrate Virtual Environment to desired Python...
  new-app                start a new app
  prepare-beta-release   Prepare major beta release from develop branch
  release                Release app (internal to the Frappe team)
  remote-reset-url       Reset app remote url to frappe official
  remote-set-url         Set app remote url
  remote-urls            Show apps remote url
  remove-app             completely remove app from bench
  renew-lets-encrypt     Renew Let's Encrypt certificate
  restart                Restart supervisor processes or systemd units
  retry-upgrade
  set-default-site       Set default site for bench
  set-mariadb-host       Set MariaDB host for bench
  set-nginx-port         Set nginx port for site
  set-ssl-certificate    Set ssl certificate path for site
  set-ssl-key            Set ssl certificate private key path for site
  set-url-root           Set url root for site
  setup                  Setup bench
  shell
  src                    Prints bench source folder path, which can be used...
  start                  Start Frappe development processes
  switch-to-branch       Switch all apps to specified branch, or specify...
  switch-to-develop      Switch frappe and erpnext to develop branch
  switch-to-master       Switch frappe and erpnext to master branch
  update                 Update bench

Framework commands:

  add-system-manager          Add a new system manager to a site
  add-to-email-queue          Add an email to the Email Queue
  auto-deploy                 Pull and migrate sites that have new version
  backup                      Backup
  browse                      Opens the site on web browser
  build                       Minify + concatenate JS and CSS files, build...
  build-docs                  Setup docs in target folder of target app
  build-message-files         Build message files for translation
  bulk-rename                 Rename multiple records via CSV file
  clear-cache                 Clear cache, doctype cache and defaults
  clear-limits                Clears given limit from the site config, and...
  clear-website-cache         Clear website cache
  console                     Start ipython console for a site
  destroy-all-sessions        Clear sessions of all users (logs them out)
  disable-scheduler           Disable scheduler
  disable-user
  doctor                      Get diagnostic info about background workers
  drop-site
  enable-scheduler            Enable scheduler
  execute                     Execute a function
  export-csv                  Export data import template with data for...
  export-doc                  Export a single document to csv
  export-fixtures             Export fixtures
  export-json                 Export doclist as json to the given path, use...
  get-untranslated            Get untranslated strings for language
  import-csv                  Import CSV using data import
  import-doc                  Import (insert/update) doclist.
  import-translations         Update translated strings
  install-app                 Install a new app to site
  jupyter
  list-apps                   List apps in site
  make-app                    Creates a boilerplate app
  mariadb                     Enter into mariadb console for a given site.
  migrate                     Run patches, sync schema and rebuild...
  mysql                       Deprecated
  new-language                Create lang-code.csv for given app
  new-site                    Create a new site
  postgres                    Enter into postgres console for a given site.
  publish-realtime            Publish realtime event from bench
  purge-jobs                  Purge any pending periodic tasks, if event...
  ready-for-migration
  rebuild-global-search       Setup help table in the current site (called...
  reinstall                   Reinstall site ie.
  reload-doc                  Reload schema for a DocType
  reload-doctype              Reload schema for a DocType
  remove-from-installed-apps  Remove app from site's installed-apps list
  request                     Run a request as an admin
  reset-perms                 Reset permissions for all doctypes
  restore                     Restore site database from an sql file
  run-patch                   Run a particular patch
  run-setup-wizard-ui-test    Run setup wizard UI test
  run-tests                   Run tests
  run-ui-tests                Run UI tests
  schedule
  scheduler
  serve                       Start development web server
  set-admin-password          Set Administrator password for a site
  set-config                  Insert/Update a value in site_config.json
  set-last-active-for-user    Set users last active date to current datetime
  set-limit                   Sets user / space / email limit for a site
  set-limits
  set-maintenance-mode
  setup-global-help           setup help table in a separate database that...
  setup-help                  Setup help table in the current site (called...
  show-config                 print configuration file
  show-pending-jobs           Get diagnostic info about background jobs
  trigger-scheduler-event     Trigger a scheduler event
  uninstall-app               Remove app and linked modules from site
  update-translations         Update translated strings
  use                         Set a default site
  version                     Show the versions of all the installed apps
  watch                       Watch and concatenate JS and CSS files as and...
  worker

I think the cause maybe that I deleted sites/ directory because of the failed site creation I described in the last reply. Is it possible to restore the sites/ directory without having to bench init every time?

You should only have to create a bench environment (bench init) once per bench.
After that, you can add or drop sites with the new-site and drop-site commands
A site includes a database, so just dropping files in the directory won’t work. You have to create the site and restore it.

You would have been better off using the new-site --force flag.

Before the whole fiasco, the new-site command failed because of some issue with numpy. As a result, the site already had a database created, but no site within the sites/ dir. And then, playing around with bench update to force pip updates in hopes of solving the aforementioned issue errored out because it couldn’t find the site directory to back it up, so bench already had a reference to the failed site somewhere. That is why I deleted the sites/ dir to mitigate the issue, but that, in hindsight, was a wrong move. Should’ve tried this drop-site switch…

But in any case, why did removing sites/ make a whole bunch of bench commands unavailable. I can’t wrap my head around that. At least it should print out an error for not finding it and have some way to repair, but it just disappears with no explanation…

Some bench commands are disabled when no sites exist, because the require a site to execute successfully. If your case where there wasn’t a directory but was a database, it didn’t know how to resolve it. Bench relies on the directory to know what to do, not the database and I think that’s the correct design decision between those two options.

That’s well and good, but where is the database stored so we can look into it once something goes haywire?

https://discuss.frappe.io/search?q=database%20location