From 080e84b74cbb0635059da3370b1c61a83968dad5 Mon Sep 17 00:00:00 2001 From: ElvisDot <43215015+ElvisDot@users.noreply.github.com> Date: Fri, 19 Jul 2024 23:05:16 +0800 Subject: [PATCH] Mention that `sudo -u postgres` throws an error (#458) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Mention that `sudo -u postgres` throws an error Running ```sudo -u postgres psql --command "CREATE ROLE \"`whoami`\" LOGIN createdb superuser;"``` in the users home folder within ubuntu WSL throws the following error ``` could not change directory to "/home/student_name": Permission denied ``` The student doing the setup is expeceted to be in his /home/username folder. Which on WSL ubuntu by default is not accessible to other users on the system. So when the `su` command switches user, the postgres user can not access the current directory and that is throwing the permission error. Which is fine because it does not have to access the current folder at all. It just has to connect to the postgres database which usually works. So the permission warning is followed by the success output `CREATE ROLE`. This might not be obvious to someone following the setup for the first time. To reduce useless debugging there is now a note hidden in a spoiler that says that this error is okay. * Update _partials/windows_postgresql.md Co-authored-by: Alexander Dubovoy <39504104+ajdubovoy@users.noreply.github.com> --------- Co-authored-by: Sébastien Saunier Co-authored-by: Alexander Dubovoy <39504104+ajdubovoy@users.noreply.github.com> --- _partials/windows_postgresql.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/_partials/windows_postgresql.md b/_partials/windows_postgresql.md index 7f47986f..e64ff3bd 100644 --- a/_partials/windows_postgresql.md +++ b/_partials/windows_postgresql.md @@ -18,6 +18,8 @@ sudo /etc/init.d/postgresql start sudo -u postgres psql --command "CREATE ROLE \"`whoami`\" LOGIN createdb superuser;" ``` +_📝 If you get an error saying `could not change directory to "/home/your_name": Permission denied` that is totally fine, and there's no need to worry 💆 If, on the first run, it says `CREATE ROLE` in the end all worked fine._ + You can configure PostgreSQL to autostart, so you don't have to execute `sudo /etc/init.d/postgresql start` each time you open a new terminal: ```bash