# Ocsigen: end of file error message

**URL:** <https://discuss.ocaml.org/t/ocsigen-end-of-file-error-message/14046>\
**Category:** Ecosystem\
**Tags:** ocsigen, ocsigen-start\
**Created:** [February 9, 2024, 1:31pm UTC](https://discuss.ocaml.org/t/ocsigen-end-of-file-error-message/14046 "2024-02-09T13:31:05Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![frederic-lang](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/frederic-lang/32/6678_2.png) [@frederic-lang](https://discuss.ocaml.org/u/frederic-lang)\
**Post date:** [February 9, 2024, 1:31pm UTC](https://discuss.ocaml.org/t/ocsigen-end-of-file-error-message/14046/1 "2024-02-09T13:31:05Z")

</div>

opam : 2.1.5  
ocaml : 4.13.1  
ocsigen-start : 6.1.2

I am trying to build a project with ocsigen-start.  
after executing commands

```auto
make db-init
make db-create
make db-schema

```

These steps perform well since I can access the db with dbeaver  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/ocaml/original/2X/2/2d0e3cb5ba3aa417bd6f2627f91030a1c195d284.png)

I try to compile the project with

```auto
make test.byte

```

but after waiting a few seconds, I receive the error

```auto
which: no sassc in (/home/frelang/.opam/4.13.1/bin:/home/frelang/.opam/4.13.1/bin:/home/frelang/.local/bin:/home/frelang/bin:/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/sbin:/usr/bin:/usr/sbin:/usr/local/bin)
which: no sassc in (/home/frelang/.opam/4.13.1/bin:/home/frelang/.opam/4.13.1/bin:/home/frelang/.local/bin:/home/frelang/bin:/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/sbin:/usr/bin:/usr/sbin:/usr/local/bin)
dune build @myeliomapp
File "demo_pgocaml_db.ml", line 13, characters 4-59:
13 | [%pgsql dbh "SELECT lastname FROM ocsigen_start.users"])
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: PG'OCaml PPX error: Could not make the connection host=localhost, port=5432, user=frelang, password= ***** , database=frelang, error: End_of_file
make: *** [Makefile.os:171: byte] Error 1

```

which is not very precise.

- for now, I am not sure to have sass well installed. But it should not make the compilation fail
- Compilation is faling because of database connection error, which I do not understand because my credentials are correct.
- the sql query looks correct; since it is querying the users table in the ocsigen\_start schema.

also when I go the demo\_pgocaml\_db.ml file, I get the message from pgsql ppx :

```auto
PG'OCaml PPX error: Could not make the connection host=unix, port=5432,
user=frelang, password= ***** , database=frelang, error:
PGOCaml_generic.Make(Thread).Error("PGOCaml: Could not connect to
database")ocamllsp

```

---

<div class="post-metadata">

**Author:** ![Vincent\_Balat](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/vincent_balat/32/2191_2.png) [@Vincent\_Balat](https://discuss.ocaml.org/u/Vincent_Balat)\
**Post date:** [February 9, 2024, 2:08pm UTC](https://discuss.ocaml.org/t/ocsigen-end-of-file-error-message/14046/2 "2024-02-09T14:08:35Z")

</div>

Hello,  
Did you get an error message while creating the database?  
Can you connect to the database with `make db-psql`?  
Maybe PostgreSQL is not running? Can you try `make db-start`?  
You can also try to remove directory `local_db` and restart creating the db (`make db-stop`, then `make db-init` etc.)  
Keep us updated

---

<div class="post-metadata">

**Author:** ![frederic-lang](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/frederic-lang/32/6678_2.png) [@frederic-lang](https://discuss.ocaml.org/u/frederic-lang)\
**Post date:** [February 9, 2024, 2:34pm UTC](https://discuss.ocaml.org/t/ocsigen-end-of-file-error-message/14046/3 "2024-02-09T14:34:16Z")

</div>

`make db-psql` works well, I can access the psql cli.  
when I try `make db-start` or `make db-stop`,  
I receive the message

```auto
make db-start
which: no sassc in (/home/frelang/.opam/4.13.1/bin:/home/frelang/.local/bin:/home/frelang/bin:/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin)
which: no sassc in (/home/frelang/.opam/4.13.1/bin:/home/frelang/.local/bin:/home/frelang/bin:/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin)
/usr/bin/pg_ctl -o "-p 5432" start
pg_ctl: no database directory specified and environment variable PGDATA unset
Try "pg_ctl --help" for more information.

```

I use the default deamon of postgresql, meaning I have the parameter  
`LOCAL := no`  
in Makefile.options

---

<div class="post-metadata">

**Author:** ![otini](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/otini/32/3533_2.png) [@otini](https://discuss.ocaml.org/u/otini)\
**Post date:** [February 9, 2024, 2:35pm UTC](https://discuss.ocaml.org/t/ocsigen-end-of-file-error-message/14046/4 "2024-02-09T14:35:49Z")

</div>

Not sure what to do with this error when `LOCAL` is `no`, personally when I have this message `make db-start` fixes it, but I didn’t modify the default postgresql options.

---

<div class="post-metadata">

**Author:** ![Haudegen](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/haudegen/32/716_2.png) [@Haudegen](https://discuss.ocaml.org/u/Haudegen)\
**Post date:** [February 9, 2024, 2:40pm UTC](https://discuss.ocaml.org/t/ocsigen-end-of-file-error-message/14046/5 "2024-02-09T14:40:02Z")

</div>

Do you use PostgreSQL \>= 14.0? PostgreSQL switched the hashing algorithm for role passwords from `MD5` to `SCRAM-SHA-256` in version 14, which causes the PG’OCaml PPX to fail.

So you can use a current PostgreSQL version, but you have to find a way to create a password hashed with the old `MD5` algorithm. I don’t think it’s possible to do that with PostgreSQL 16 (which is the current stable version).

So if you want to use OCsigen with PostgreSQL 16, you’ll have to install PostgreSQL 13, create your role(s) and then upgrade your cluster to PostgreSQL 16. Or you create your hashes outside of PostgreSQL and manually update `rolepassword` in the table `pg_authid`. But I don’t know whether that works, haven’t tried it.

There is an issue on GitHub for this: [PPX is broken for PG version \>= 14.0 (default scram-sha-256 auth is not handled) · Issue #120 · darioteixeira/pgocaml · GitHub](https://github.com/darioteixeira/pgocaml/issues/120)

---

<div class="post-metadata">

**Author:** ![frederic-lang](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/frederic-lang/32/6678_2.png) [@frederic-lang](https://discuss.ocaml.org/u/frederic-lang)\
**Post date:** [February 9, 2024, 2:40pm UTC](https://discuss.ocaml.org/t/ocsigen-end-of-file-error-message/14046/6 "2024-02-09T14:40:08Z")

</div>

When I try initialisation with `LOCAL := yes`,  
I get the message from `make db-init` :

```auto
*which: no sassc in (/home/frelang/.opam/4.13.1/bin:/home/frelang/.local/bin:/home/frelang/bin:/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin)
which: no sassc in (/home/frelang/.opam/4.13.1/bin:/home/frelang/.local/bin:/home/frelang/bin:/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin)
mkdir -p local_db
/usr/bin/pg_ctl initdb -o --encoding=UNICODE -D local_db
The files belonging to this database system will be owned by user "frelang".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory local_db ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Europe/Paris
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    /usr/bin/pg_ctl -D local_db -l logfile start

echo unix_socket_directories = \'/tmp\' >> local_db/postgresql.conf
/usr/bin/pg_ctl -o "-p 5432" -D local_db -l local_db/log start
waiting for server to start.... stopped waiting
pg_ctl: could not start server
Examine the log output.
make: *** [Makefile.db:102: db-init] Error 1

```

---

<div class="post-metadata">

**Author:** ![otini](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/otini/32/3533_2.png) [@otini](https://discuss.ocaml.org/u/otini)\
**Post date:** [February 9, 2024, 2:42pm UTC](https://discuss.ocaml.org/t/ocsigen-end-of-file-error-message/14046/7 "2024-02-09T14:42:11Z")

</div>

What does the log say?

---

<div class="post-metadata">

**Author:** ![frederic-lang](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/frederic-lang/32/6678_2.png) [@frederic-lang](https://discuss.ocaml.org/u/frederic-lang)\
**Post date:** [February 9, 2024, 2:43pm UTC](https://discuss.ocaml.org/t/ocsigen-end-of-file-error-message/14046/8 "2024-02-09T14:43:28Z")

</div>

in local\_db/log :

```auto
2024-02-09 15:37:09.114 CET [464681] FATAL: could not open log file "log/postgresql-Fri.log": Not a directory
2024-02-09 15:37:09.115 CET [464681] LOG: database system is shut down

```

---

<div class="post-metadata">

**Author:** ![Vincent\_Balat](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/vincent_balat/32/2191_2.png) [@Vincent\_Balat](https://discuss.ocaml.org/u/Vincent_Balat)\
**Post date:** [February 9, 2024, 3:00pm UTC](https://discuss.ocaml.org/t/ocsigen-end-of-file-error-message/14046/9 "2024-02-09T15:00:33Z")

</div>

It’s probably related to LOCAL=no indeed. I didn’t know this feature existed 😅 but it might be broken.  
Maybe it left some wrong configuration in local\_db.  
Can you try to remove the directory `local_db` and restart with LOCAL=yes?

---

<div class="post-metadata">

**Author:** ![frederic-lang](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/frederic-lang/32/6678_2.png) [@frederic-lang](https://discuss.ocaml.org/u/frederic-lang)\
**Post date:** [February 9, 2024, 4:10pm UTC](https://discuss.ocaml.org/t/ocsigen-end-of-file-error-message/14046/10 "2024-02-09T16:10:31Z")

</div>

I retried with the LOCAL=yes parameter, but I get after executing `make db-init`

```auto
/usr/bin/pg_ctl -o "-p 5432" -D local_db -l local_db/log start
waiting for server to start.... stopped waiting
pg_ctl: could not start server
Examine the log output.

```

and the log file contains

```auto
2024-02-09 17:04:10.515 CET [497632] FATAL: could not open log file "log/postgresql-Fri.log": Not a directory
2024-02-09 17:04:10.515 CET [497632] LOG: database system is shut down

```

Not sure it comes from postgresql version, because I tried with postgresql13-server installed

---

<div class="post-metadata">

**Author:** ![Vincent\_Balat](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/vincent_balat/32/2191_2.png) [@Vincent\_Balat](https://discuss.ocaml.org/u/Vincent_Balat)\
**Post date:** [February 9, 2024, 4:27pm UTC](https://discuss.ocaml.org/t/ocsigen-end-of-file-error-message/14046/11 "2024-02-09T16:27:26Z")

</div>

You might still have a postgresql server running on this port?  
Try to kill it and retry (or use another port)

---

<div class="post-metadata">

**Author:** ![frederic-lang](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/frederic-lang/32/6678_2.png) [@frederic-lang](https://discuss.ocaml.org/u/frederic-lang)\
**Post date:** [February 9, 2024, 4:37pm UTC](https://discuss.ocaml.org/t/ocsigen-end-of-file-error-message/14046/12 "2024-02-09T16:37:42Z")

</div>

For now I have two services but none of them is active 😒

 ![image](https://us1.discourse-cdn.com/flex020/uploads/ocaml/original/2X/c/ce15f11149cf0a5be0730686950eaa5bd0cd83cd.png)

---

<div class="post-metadata">

**Author:** ![Vincent\_Balat](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/vincent_balat/32/2191_2.png) [@Vincent\_Balat](https://discuss.ocaml.org/u/Vincent_Balat)\
**Post date:** [February 9, 2024, 5:06pm UTC](https://discuss.ocaml.org/t/ocsigen-end-of-file-error-message/14046/13 "2024-02-09T17:06:28Z")

</div>

Maybe try `killall postgres`?

---

<div class="post-metadata">

**Author:** ![frederic-lang](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/frederic-lang/32/6678_2.png) [@frederic-lang](https://discuss.ocaml.org/u/frederic-lang)\
**Post date:** [February 13, 2024, 1:23pm UTC](https://discuss.ocaml.org/t/ocsigen-end-of-file-error-message/14046/14 "2024-02-13T13:23:51Z")

</div>

Finnally I discovered the error :

The point is to run postgresql with provided commands in makefile and not with systemctl commands, which are pointed out on tutorials that can be found on the web. Runnig postgres as a daemon was triggering the bug, unlike make commands that use pg\_ctl.

My example app is running with Postgres 15.4.

---

<div class="post-metadata">

**Author:** ![Vincent\_Balat](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/vincent_balat/32/2191_2.png) [@Vincent\_Balat](https://discuss.ocaml.org/u/Vincent_Balat)\
**Post date:** [February 13, 2024, 1:29pm UTC](https://discuss.ocaml.org/t/ocsigen-end-of-file-error-message/14046/15 "2024-02-13T13:29:35Z")

</div>

Great thanks. It would be interesting to investigate. Maybe a wrong port configuration somewhere?  
Do not hesitate if you have more questions.
