Search code examples
postgresqlunixfile-permissions

Installing Postgres custom type - could not access file "...": Permission denied


Using postgres11, I'm trying to register the example Complex type that comes in the source distribution.

I've built the type without any problems:

git clone https://github.com/postgres/postgres.git
cd postgres/src/tutorial
make

But when I try to install it, I run into a permission problem:

~/p/s/tutorial> psql -U postgres -W 
Password: 
psql (11.2 (Debian 11.2-1.pgdg90+1))
Type "help" for help.

postgres=# \c testdata
Password for user postgres: 
You are now connected to database "testdata" as user "postgres".
testdata=# 
testdata=# \i complex.sql
psql:complex.sql:39: NOTICE:  type "complex" is not yet defined
DETAIL:  Creating a shell type definition.
psql:complex.sql:39: ERROR:  could not access file "/home/mnuttall/postgres/src/tutorial/complex": Permission denied
psql:complex.sql:47: ERROR:  type complex does not exist

I'm not sure where exactly the permission problem is coming from, as I've changed the permissions for everything in the src/tutorial directory to 777.

Anyone have an idea?


Solution

  • It looks like your home directory is not accessible to system user postgres.

    You need to make sure that the permissions of the directories above allow user postgres to enter the directory (r-x). So possible solution would be to run:

    $ chmod o+rx $HOME
    

    If this doesn't help make sure to run the command on every other directory in the path as well.