ERROR: invalid locale name: "en_US.UTF-8"

Hi all,

I am installing AiiDA in WSL2, but during quicksetup I ran into following error. Can you please help me to resolve this?

(aiida) rkarkee@RKARKEE:~$ verdi quicksetup
/home/rkarkee/envs/aiida/lib/python3.10/site-packages/aiida/manage/configuration/settings.py:59: UserWarning: Creating AiiDA configuration folder `/home/rkarkee/.aiida`.
  warnings.warn(f'Creating AiiDA configuration folder `{path}`.')
Report: enter ? for help.
Report: enter ! to ignore the default and set no value.
Profile name [quicksetup]: rkee
Email Address (for sharing data): rijankarkee@gmail.com
First name [John]: Rijan
Last name [Doe]: Karkee
Institution [Unknown]:
Trying to become 'postgres' user. You may be asked for your 'sudo' password.
[sudo] password for rkarkee:
Trying to become 'postgres' user. You may be asked for your 'sudo' password.
Trying to become 'postgres' user. You may be asked for your 'sudo' password.
Trying to become 'postgres' user. You may be asked for your 'sudo' password.
Trying to become 'postgres' user. You may be asked for your 'sudo' password.
Trying to become 'postgres' user. You may be asked for your 'sudo' password.
ERROR:  invalid locale name: "en_US.UTF-8"

Error: Oops! quicksetup was unable to create the AiiDA database for you.
            See `verdi quicksetup -h` for how to specify non-standard parameters for the postgresql connection.
            Alternatively, create the AiiDA database yourself:

            Run the following commands as a UNIX user with access to PostgreSQL (Ubuntu: $ sudo su postgres):

        $ psql template1
        ==> CREATE USER "aiida_qs_rkarkee_c67355a95f0f30138e43b517f5e739a9" WITH PASSWORD '<password>'
        ==> GRANT "aiida_qs_rkarkee_c67355a95f0f30138e43b517f5e739a9" TO current_user
        ==> CREATE DATABASE "rkee_rkarkee_c67355a95f0f30138e43b517f5e739a9" OWNER "aiida_qs_rkarkee_c67355a95f0f30138e43b517f5e739a9" ENCODING 'UTF8' LC_COLLATE='en_US.UTF-8' LC_CTYPE='en_US.UTF-8' TEMPLATE=template0

            and then use `verdi setup` instead.

Traceback (most recent call last):
  File "/home/rkarkee/envs/aiida/bin/verdi", line 8, in <module>
    sys.exit(verdi())
  File "/home/rkarkee/envs/aiida/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/rkarkee/envs/aiida/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/rkarkee/envs/aiida/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/rkarkee/envs/aiida/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/rkarkee/envs/aiida/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/rkarkee/envs/aiida/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/rkarkee/envs/aiida/lib/python3.10/site-packages/aiida/cmdline/commands/cmd_setup.py", line 224, in quicksetup
    raise exception
  File "/home/rkarkee/envs/aiida/lib/python3.10/site-packages/aiida/cmdline/commands/cmd_setup.py", line 214, in quicksetup
    db_username, db_name = postgres.create_dbuser_db_safe(dbname=db_name, dbuser=db_username, dbpass=db_password)
  File "/home/rkarkee/envs/aiida/lib/python3.10/site-packages/aiida/manage/external/postgres.py", line 223, in create_dbuser_db_safe
    self.create_db(dbuser=dbuser, dbname=dbname)
  File "/home/rkarkee/envs/aiida/lib/python3.10/site-packages/aiida/manage/external/postgres.py", line 169, in create_db
    self.execute(_CREATE_DB_COMMAND.format(dbname, dbuser))
  File "/home/rkarkee/envs/aiida/lib/python3.10/site-packages/pgsu/__init__.py", line 120, in execute
    return _execute_su_psql(command, dsn)
  File "/home/rkarkee/envs/aiida/lib/python3.10/site-packages/pgsu/__init__.py", line 368, in _execute_su_psql
    proc.check_returncode()
  File "/usr/lib/python3.10/subprocess.py", line 457, in check_returncode
    raise CalledProcessError(self.returncode, self.args, self.stdout,
subprocess.CalledProcessError: Command '['sudo', '-n', 'su', 'postgres', '-c', 'cd ~ && psql -d template1 -p 5432 -tc \'CREATE DATABASE "rkee_rkarkee_c67355a95f0f30138e43b517f5e739a9" OWNER "aiida_qs_rkarkee_c67355a95f0f30138e43b517f5e739a9" ENCODING \'"\'"\'UTF8\'"\'"\' LC_COLLATE=\'"\'"\'en_US.UTF-8\'"\'"\' LC_CTYPE=\'"\'"\'en_US.UTF-8\'"\'"\' TEMPLATE=template0\'']' 

The error about the invalid locale name is not the cause of the failure. To create the database in PSQL, your sudo password is needed. AiiDA tried to do it automatically, but it cannot because of this. You will have to create the database manually and then use verdi setup instead. Please follow these instructions in the documentation: Advanced configuration — AiiDA 2.5.1.post0 documentation

Hi @sphuber

I followed the link you suggested but got another error.

(aiida) rkarkee@RKARKEE:~$ sudo su - postgres
[sudo] password for rkarkee:
Welcome to Ubuntu 22.04.4 LTS (GNU/Linux 5.15.133.1-microsoft-standard-WSL2 x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

 * Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
   just raised the bar for easy, resilient and secure K8s cluster deployment.

   https://ubuntu.com/engage/secure-kubernetes-at-the-edge

This message is shown once a day. To disable it please create the
/var/lib/postgresql/.hushlogin file.
postgres@RKARKEE:~$ psql
psql (14.10 (Ubuntu 14.10-0ubuntu0.22.04.1))
Type "help" for help.

postgres=# CREATE USER aiida WITH PASSWORD 'aiidalearn';
CREATE ROLE
postgres=# CREATE DATABASE aiidadb OWNER aiida ENCODING 'UTF8' LC_COLLATE='en_US.UTF-8' LC_CTYPE='en_US.UTF-8' TEMPLATE=template0;
ERROR:  invalid locale name: "en_US.UTF-8"
postgres=# CREATE DATABASE aiidadb OWNER aiida ENCODING 'UTF8' LC_COLLATE='en_US.UTF-8' LC_CTYPE='en_US.UTF-8' TEMPLATE=template0;
ERROR:  invalid locale name: "en_US.UTF-8"

Dear @rkarkee, thanks for your questions. This is what a simple google search for your error (ERROR: invalid locale name: "en_US.UTF-8") shows:

I would suggest that you try the accepted answer there, that I think should solve your issue.

In general, while we are all very willing to help, it would be great if you could try to look for a solution online, especially for problems that are not directly related to AiiDA but e.g. to PostgreSQL, and for which typically solutions can be found online (we would anyway have to google ourselves to find the solution and reply to you :slight_smile: ).
This will also speed up the resolution of your problem, as you can move to the next potential issue (or to a working installation!) immediately, rather than have to wait for an answer from us.

Of course, if you search online and cannot find a solution, feel free to post here.

Hi @giovannipizzi

Sorry for the confusion, as I am new to unix system I thought PostgresSQL is related to AiiDA, apparently it isnt.
I went to that link and fixed the issue.

As suggested by @sphuber I went through Advanced Configuration in verdi setup, and created a profile

(aiida) rkarkee@RKARKEE:~$ verdi setup
Report: enter ? for help.
Report: enter ! to ignore the default and set no value.
Profile name: rkee
Email Address (for sharing data) [rijankarkee@gmail.com]:
First name [Rijan]:
Last name [Karkee]:
Institution [Unknown]: UCM
Database engine (postgresql_psycopg2) [postgresql_psycopg2]:
Database backend (core.psql_dos) [core.psql_dos]:
Database host [localhost]:
Database port [5432]:
Database name: aiidadb
Database username: aiida
Database password:
Broker protocol (amqp, amqps) [amqp]:
Broker username [guest]:
Broker password [guest]:
Broker host [127.0.0.1]:
Broker port [5672]:
Broker virtual host name []:
Repository directory [/home/rkarkee/.aiida/repository/rkee]:
Report: initialising the profile storage.
Report: initialising empty storage schema
Report: Migrating to the head of the main branch
Success: storage initialisation completed.
Success: created new profile `rkee`.

I am confused whether I also need to do. ## Database setup using ‘peer’ authentication Is that compulsary to do?

After verdi setup success, I did
verdi daemon start 2

Then my verdi status looks like the following which complains incompatible rabbitmq.

(aiida) rkarkee@RKARKEE:~$ verdi status
 ✔ version:     AiiDA v2.5.1
 ✔ config:      /home/rkarkee/.aiida
 ✔ profile:     rkee
 ✔ storage:     Storage for 'rkee' [open] @ postgresql://aiida:***@localhost:5432/aiidadb / DiskObjectStoreRepository: 493c766da9614dc5ac0c32fe379bef27 | /home/rkarkee/.aiida/repository/rkee/container
Warning: RabbitMQ v3.9.13 is not supported and will cause unexpected problems!
Warning: It can cause long-running workflows to crash and jobs to be submitted multiple times.
Warning: See https://github.com/aiidateam/aiida-core/wiki/RabbitMQ-version-to-use for details.
 ⏺ rabbitmq:    Incompatible RabbitMQ version detected! Connected to RabbitMQ v3.9.13 as amqp://guest:guest@127.0.0.1:5672?heartbeat=600
 ✔ daemon:      Daemon is running with PID 76997

No, the peer authentication is optional, you can skip it. If you fixed the RabbitMQ configuration as you mentioned in the other thread then everything is OK!