Skip to content

Commit

Permalink
Mention that sudo -u postgres throws an error (#458)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

---------

Co-authored-by: Sébastien Saunier <[email protected]>
Co-authored-by: Alexander Dubovoy <[email protected]>
  • Loading branch information
3 people authored Jul 19, 2024
1 parent 00c85c8 commit 080e84b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions _partials/windows_postgresql.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 080e84b

Please sign in to comment.