BUG #18671: Unable to Run PostgreSQL on EndeavourOS without Modifying visudo

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: rq_(at)tutanota(dot)com
Subject: BUG #18671: Unable to Run PostgreSQL on EndeavourOS without Modifying visudo
Date: 2024-10-24 14:30:35
Message-ID: 18671-0c75cf63b404ca20@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 18671
Logged by: rqbin
Email address: rq_(at)tutanota(dot)com
PostgreSQL version: 16.3
Operating system: EndeavourOS (Arch Distro)
Description:

**Watch in a .md editor for better view**

I encountered significant issues when attempting to run PostgreSQL on my
EndeavourOS system. Despite following all standard installation procedures,
I was unable to start PostgreSQL or perform necessary administrative tasks
such as initializing the database. After trying multiple fixes, the only
solution was to modify `visudo` to allow `postgres` to run with
administrative privileges, which should not be necessary.

### **Steps to Reproduce**

1. Installed PostgreSQL via `pacman`:
```bash
sudo pacman -S postgresql
```

2. Tried to initialize the PostgreSQL database:
```bash
sudo su - postgres
initdb --locale=C.UTF-8 --encoding=UTF8 -D '/var/lib/postgres/data'
```

3. Encountered permission issues:
```bash
initdb: error: could not access directory "/var/lib/postgres/data":
Permission denied
```

4. I attempted the following common solutions:
- Resetting the `postgres` user password.
- Ensuring that the `postgres` user had the appropriate privileges and
was part of necessary groups.
- Starting and enabling the PostgreSQL service via `systemctl`.

None of these steps resolved the issue. I also attempted the recommended
commands such as:
```bash
sudo -u postgres -i
```
But continued to be prompted for a password, which was not accepted
despite resetting it multiple times.

5. The **only** workaround that enabled me to start PostgreSQL successfully
was modifying `visudo` to grant additional privileges to the `postgres`
user.

### **Expected Behavior**

PostgreSQL should run without needing to modify `visudo`. The default
installation and initialization procedures should allow the `postgres` user
to perform administrative tasks without requiring extra steps.

### **System Information**

To provide more insight into my system configuration, here are the specs of
my machine:

Operating System: EndeavourOS (Arch-based)
Kernel Version: 6.6.56-1-lts (64-bit)
Laptop Model: ASUS Vivobook M3401QA
CPU: AMD Ryzen 5 5600H (6 cores, 12 threads, base clock: 2.47 GHz, max
clock: 4.28 GHz)
GPU: AMD Radeon Vega (integrated)
Memory: 8 GB RAM (available: 7.17 GB, used: 6.08 GB)

### **Logs and Outputs**

Here are some relevant logs and error messages from my attempts:

1. **PostgreSQL Service Status:**
```bash
sudo systemctl status postgresql.service
```
Output:
```
× postgresql.service - PostgreSQL database server
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled;
preset: disabled)
Active: failed (Result: exit-code) since [time];
...
/var/lib/postgres/data is missing or empty.
Failed with result 'exit-code'.
```

2. **Permission Denied Error on `initdb`:**
```bash
initdb: error: could not access directory "/var/lib/postgres/data":
Permission denied
```

### **Solution Attempted**

I modified `/etc/sudoers` via `visudo` to allow `postgres` to run with more
privileges. This workaround allowed me to start PostgreSQL successfully, but
this is not ideal and should not be the expected behavior.

---

If this issue is specific to EndeavourOS or PostgreSQL on Arch-based
systems, it would be helpful to identify and address the root cause to
improve the experience for future users.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2024-10-24 15:31:54 Re: BUG #18671: Unable to Run PostgreSQL on EndeavourOS without Modifying visudo
Previous Message Павел Некрасов 2024-10-24 09:09:10 Re: BUG #18614: [ECPG] out of bound in DecodeDateTime