Postgis Plugin Error - function function carto_path_type does not exist

Hi

Was following the install guide at Manually building a tile server (Ubuntu 22.04) – Switch2OSM

During the service restart I see the following error message in the logs

encountered during parsing of layer 'tunnels' in Layer at line 14780 of '/home/mapper/src/openstreetmap-carto/mapnik.xml'
** (process:14961): ERROR **: 03:32:49.011: An error occurred while loading the map layer 's2o': Postgis Plugin: ERROR:  function carto_path_type(text, text) does not exist
LINE 15: ...   'highway_' || (CASE WHEN highway = 'path' THEN carto_path...                                                                                                                                                   
                                                               ^                                                                                                        
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
in executeQuery Full sql was: 'SELECT * FROM (SELECT 

Anybody else experienced this, I hope I did not skip any steps during the install

Looking at the error, I started to search for that sql function and found a create statement of it in ~/src/openstreetmap-carto/functions.sql

So executed that on the gis database and restarted the services

So now my tile server is working.

Still not sure what I skipped or missed in the guide.

2 Likes

SQL functions have been introduced into the freshly released 5.9.0 Carto release. The Switch2OSM guide will need tweaking.

2 Likes

I haven’t tested it yet, but I’ve added https://github.com/switch2osm/switch2osm/pull/269. If no one objects I’ll merge that in a couple of days.

Edit: Now merged

Looks good to me. As you state, functions.sql can be safely applied whether it has been previously executed or not.

It might be worth adding that failure to load the functions will result in errors like ERROR: function carto_path_type(text, text) does not exist so users can recognise what has gone wrong if they miss this step.

Actually, someone has pointed out another issue here - OSM Carto is in the process of switching over to using flex rather than pgsql output from osm2pgsql. To get to what was released on osm.org (tag 5.9.0) you need to do something like this:

git clone https://github.com/gravitystorm/openstreetmap-carto
cd openstreetmap-carto
git pull --all
git switch --detach v5.9.0

That worked for me on a new Debian 12 system, and if no-one suggests a better way either here or at github I’ll change the other “up to date” guides too.