maptiler / tileserver-gl

Vector and raster maps with GL styles. Server side rendering by MapLibre GL Native. Map tile server for MapLibre GL JS, Android, iOS, Leaflet, OpenLayers, GIS via WMTS, etc.
https://tileserver.readthedocs.io/en/latest/
Other
2.19k stars 632 forks source link

Error installing version 4.1.2 with Node 16.18.0 #643

Open bdmapman opened 1 year ago

bdmapman commented 1 year ago

I am trying to install Tileserver-GL 4.1.2 version with node 16.18.0. I am directly using the following command

npm install -g tileserver-gl

The following error returning

npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm ERR! code 127
npm ERR! path /root/.nvm/versions/node/v16.18.0/lib/node_modules/tileserver-gl/node_modules/sqlite3
npm ERR! command failed
npm ERR! command sh -c -- node-pre-gyp install --fallback-to-build
npm ERR! sh: 1: node-pre-gyp: Permission denied

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-11-16T08_31_08_685Z-debug-0.log
acalcutt commented 1 year ago

I've seen this when installing globally as a root user. if you run as a different user does it happen?

bdmapman commented 1 year ago

Now occurred different problem After running the installation it return the following with no errors

npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142

added 409 packages, and audited 410 packages in 36s

56 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
npm notice 
npm notice New major version of npm available! 8.19.2 -> 9.1.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.1.1
npm notice Run npm install -g npm@9.1.1 to update!
npm notice

Now when I am trying to run tileserver-gl --version it is returning the following

node:internal/modules/cjs/loader:1239
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: libGLX.so.0: cannot open shared object file: No such file or directory
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1239:18)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12)
    at Module.require (node:internal/modules/cjs/loader:1057:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/home/geodevops/.nvm/versions/node/v16.18.0/lib/node_modules/tileserver-gl/node_modules/@maplibre/maplibre-gl-native/platform/node/index.js:5:12)
    at Module._compile (node:internal/modules/cjs/loader:1155:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12) {
  code: 'ERR_DLOPEN_FAILED'
}
acalcutt commented 1 year ago

when running without docker you need the native dependencies. https://tileserver.readthedocs.io/en/latest/installation.html#npm

The maplibre-native binaries are build with ubuntu 20.04, so it works best with that OS, but there are also instructions for debian 11 on the doc page.

acalcutt commented 1 year ago

I think lib GLX is libgles2-mesa-dev (ubuntu) / libgles2-mesa (debian)

bdmapman commented 1 year ago

I am directly running npm install -g tileserver-gl without installing dependencies. Do I need to install dependencies?

acalcutt commented 1 year ago

yes. if you are not running the docker version you need those dependencies installed on the system.

The docker version pre-installs all the dependencies https://github.com/maptiler/tileserver-gl/blob/master/Dockerfile#L8-L24 into the image, so it does not need them installed on the running system.

bdmapman commented 1 year ago

No luck. I have installed the following dependencies. I know there are duplicates and unnecessary libraries but see my approaches

Trial: 1

  1. Added new sudo user and login with the user as you told earlier root user will create a problem
  2. Installed node 16.18.0
  3. OS: Ubuntu 22.04
  4. Now installed the dependencies by
    sudo apt-get install -y software-properties-common protobuf-compiler pkg-config libcairo2-dev \
    libjpeg-dev libgif-dev git libgl1-mesa-glx build-essential g++ curl \
    libgles2-mesa libegl1-mesa libgles2-mesa-dev libjpeg8-dev \
    libpango1.0-dev xvfb libgbm-dev libxxf86vm-dev
  5. git clone https://github.com/maptiler/tileserver-gl.git
  6. entered the tileserver-gl directory and ran npm install

It returns the following

npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported

> tileserver-gl@4.1.3 prepare
> node -e "if (process.env.NODE_ENV !== 'production'){ process.exit(1) } " || husky install

husky - Git hooks installed

added 791 packages, and audited 792 packages in 23s

126 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
npm notice 
npm notice New major version of npm available! 8.19.2 -> 9.1.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.1.1
npm notice Run npm install -g npm@9.1.1 to update!
npm notice

After that when I am running tileserver-gl --version it returnsbash: tileserver-gl: command not found`

Trial: 2

  1. Added new sudo user and login with the user as you told earlier root user will create a problem
  2. Installed node 16.18.0
  3. OS: Ubuntu 22.04
  4. Now installed the dependencies by
    sudo apt-get install -y software-properties-common protobuf-compiler pkg-config libcairo2-dev \
    libjpeg-dev libgif-dev git libgl1-mesa-glx build-essential g++ curl \
    libgles2-mesa libegl1-mesa libgles2-mesa-dev libjpeg8-dev \
    libpango1.0-dev xvfb libgbm-dev libxxf86vm-dev
  5. Ran npm install -g tileserver-gl directly

It returns the following

npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142

added 409 packages, and audited 410 packages in 33s

56 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

After that when I am running `tileserver-gl --version it returns the previous one

node:internal/modules/cjs/loader:1239
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: libuv.so.1: cannot open shared object file: No such file or directory
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1239:18)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12)
    at Module.require (node:internal/modules/cjs/loader:1057:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/home/geodevops/.nvm/versions/node/v16.18.0/lib/node_modules/tileserver-gl/node_modules/@maplibre/maplibre-gl-native/platform/node/index.js:5:12)
    at Module._compile (node:internal/modules/cjs/loader:1155:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12) {
  code: 'ERR_DLOPEN_FAILED'
}
acalcutt commented 1 year ago

That error looks like 'libuv1-dev'. I don't see that in the packages you installed.

Edit: although I notice that is missing from the Ubuntu dependency list. it is used in the docker image though. might have to update the docs and add that.

bdmapman commented 1 year ago

I didn't find anywhere that this libuv1-dev library is needed

acalcutt commented 1 year ago

it is in the list of debian 11 packages at https://tileserver.readthedocs.io/en/latest/installation.html#npm and used in the ubuntu docker image https://github.com/maptiler/tileserver-gl/blob/master/Dockerfile#L15 , so I'm assuming it was just missed in the ubuntu package list.

If that works for you I'd welcome a PR to update the dependency list at https://github.com/maptiler/tileserver-gl/blob/master/docs/installation.rst

bdmapman commented 1 year ago

Again no luck :D now it is returning

node:internal/modules/cjs/loader:1239
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: libicui18n.so.66: cannot open shared object file: No such file or directory
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1239:18)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12)
    at Module.require (node:internal/modules/cjs/loader:1057:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/home/devops/.nvm/versions/node/v16.18.0/lib/node_modules/tileserver-gl/node_modules/@maplibre/maplibre-gl-native/platform/node/index.js:5:12)
    at Module._compile (node:internal/modules/cjs/loader:1155:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12) {
  code: 'ERR_DLOPEN_FAILED'
}

Now it is libicui18n library?

acalcutt commented 1 year ago

'libicu66' package installed?

On debian 11 I had trouble with this library. I had to install a specific version that only existed in ubuntu. since you are in an ubuntu flavor, you might have less trouble with this.

bdmapman commented 1 year ago

I already have libicu-dev and libicu70. I am using Ubuntu: Jammy so probably libicu66 became libicu70 as libicu66 unable to locate. Still no luck

acalcutt commented 1 year ago

it probably won't work with different versions of libicu . maplibre-native binaries are looking for a specific version of libicu66 at a file called libicui18n.so.66 (on my system this in in /usr/lib/x86_64-linux-gnu/libicui18n.so.66 )

If you are running libicu70, that libicui18n.so.66 file it is looking for likely doesn't exist...probably called libicui18n.so.70 instead, or something like that.

Other than installing the version maplibre-native wants, maybe a symbolic link could be made? ln -s /usr/lib/x86_64-linux-gnu/libicui18n.so.70 /usr/lib/x86_64-linux-gnu/libicui18n.so.66 I'm not sure about that though.

acalcutt commented 1 year ago

on debian if you notice, I had to install this version from ubuntu to get it to work

http://archive.ubuntu.com/ubuntu/pool/main/i/icu/libicu66_66.1-2ubuntu2_amd64.deb

bdmapman commented 1 year ago

Yup. I was trying to run on ubuntu 20.04. It was successful. But I need it on 22.04. I am going to update all my old stuffs on a new server

bdmapman commented 1 year ago

I ran ln -s /usr/lib/x86_64-linux-gnu/libicui18n.so.70 /usr/lib/x86_64-linux-gnu/libicui18n.so.66 now it is showing Error: libicuuc.so.66: cannot open shared object file: No such file or directory

acalcutt commented 1 year ago

ya, makes sense. the maplibre-native binaries are built on ubuntu 20.04 right now, so they have some static links to libraries on that OS version. All my test servers are running 20.04 or debian 11.

For the link, is libicui18n.so.70 what the file was called, it was just a guess. do you see it if you do find /usr/lib/x86_64-linux-gnu/ -name libicui*

bdmapman commented 1 year ago
/usr/lib/x86_64-linux-gnu/libicui18n.so
/usr/lib/x86_64-linux-gnu/libicui18n.so.66
/usr/lib/x86_64-linux-gnu/libicuio.so.70
/usr/lib/x86_64-linux-gnu/libicuio.so
/usr/lib/x86_64-linux-gnu/libicuio.so.70.1
/usr/lib/x86_64-linux-gnu/libicui18n.so.70.1
/usr/lib/x86_64-linux-gnu/libicuio.a
/usr/lib/x86_64-linux-gnu/libicui18n.a
/usr/lib/x86_64-linux-gnu/libicui18n.so.70
acalcutt commented 1 year ago

so that probably should have been

ln -s /usr/lib/x86_64-linux-gnu/libicui18n.so.70.1 /usr/lib/x86_64-linux-gnu/libicui18n.so.66

bdmapman commented 1 year ago

Again deploy a new ubuntu 22.04 and started from scratch and install npm install -g tileserver-gl.

after that created a symbolic link ln -s /usr/lib/x86_64-linux-gnu/libicui18n.so.70.1 /usr/lib/x86_64-linux-gnu/libicui18n.so.66. But still returning

Error: libicuuc.so.66: cannot open shared object file: No such file or directory

acalcutt commented 1 year ago

Other than seeing if you can remove 'libicu70' and trying to install 'libicu66' from http://archive.ubuntu.com/ubuntu/pool/main/i/icu/libicu66_66.1-2ubuntu2_amd64.deb , I'm out of ideas for this maptiler version.

Any other solution would require compiling your own maplibre-native binary. not sure how far down the rabbit hole you want to go :-) ,

To build the maplibre-native binaries on linux, I would do something like these steps... like https://github.com/maplibre/maplibre-gl-native/tree/main/platform/linux

apt-get install libjpeg-dev libpng-dev ccache cmake ninja-build pkg-config xvfb libcurl4-openssl-dev libglfw3-dev libuv1-dev libicu-dev libjpeg-turbo8 g++-10 libc++-9-dev libc++abi-9-dev libjpeg-turbo8 libicu70

git clone --recurse-submodules https://github.com/maplibre/maplibre-gl-native.git

cd maplibre-gl-native

cmake . -B build -G Ninja -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10

cmake --build build -j $(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null)

After running these commands, you should end up with a 'lib' folder with binaries for each node version for the OS you built it on. you could likely place these in node_modules/@maplibre/maplibre-gl-native/lib (overwriting the downloaded ones)

acalcutt commented 1 year ago

I'm going to do some testing with my version of tileserver at https://github.com/acalcutt/tileserver-gl . In my version I have a customized maplibe-native that will build on its own if binaries don't exists. It may be possible to force it to build with

apt-get install libjpeg-dev libpng-dev ccache cmake ninja-build pkg-config xvfb libcurl4-openssl-dev libglfw3-dev libuv1-dev libicu-dev libjpeg-turbo8 g++-10 libc++-9-dev libc++abi-9-dev libjpeg-turbo8 libicu70

npm install -g @acalcutt/tileserver-gl --build-from-source=@acalcutt/maplibre-gl-native
bdmapman commented 1 year ago

libc++-9-dev & libc++abi-9-dev packages were not found

bdmapman commented 1 year ago

Also return

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/c/curl/libcurl4-openssl-dev_7.81.0-1ubuntu1.4_amd64.deb  404  Not Found [IP: 91.189.91.38 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
bdmapman commented 1 year ago

Happy GIS day 🚀🚀🚀

acalcutt commented 1 year ago

So I finally had a chance to try this on ubuntu 22.04 and was able to get it working by building my own maplibre-native.

The steps looked like this

Build maplinre-native lib files based on https://github.com/acalcutt/maplibre-gl-native/tree/main/platform/linux with updated package name

  1. apt install ccache cmake ninja-build pkg-config xvfb libcurl4-openssl-dev libglfw3-dev libuv1-dev g++-10 libc++-dev libc++abi-dev libpng-dev libgl1-mesa-dev libgl1-mesa-dri libjpeg-dev
  2. git clone --recurse-submodules -j8 https://github.com/maplibre/maplibre-gl-native.git
  3. cd maplibre-gl-native
  4. npm i --ignore-scripts (note, if you forget this, you will get a warning that node modules will not be built when building, which we are trying to do here)
  5. cmake . -B build -G Ninja -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10
  6. cmake --build build -j $(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null)
  7. If all is successful your should end up with node libraries in maplibre-gl-native/libs

Tileserver-gl Install

  1. git clone https://github.com/maptiler/tileserver-gl.git
  2. cd tileserver-gl
  3. npm i
  4. Test running, it should fail with a libicui18n.so.66 error
  5. delete the folders in 'tileserver-gl/node_modules/@maplibre/maplibre-gl-native/lib'
  6. copy the node lib folders from 'maplibre-native/lib' you created into 'tileserver-gl/node_modules/@maplibre/maplibre-gl-native/lib'
  7. try starting tileserver-gl again. , it should hopefully look like this
    
    # lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description:    Ubuntu 22.04.1 LTS
    Release:        22.04
    Codename:       jammy

xvfb-run --server-args="-screen 0 1024x768x24" node .

Starting tileserver-gl v4.2.0 No MBTiles found [DEMO] Downloading sample data (zurich_switzerland.mbtiles) from https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/zurich_switzerland.mbtiles [INFO] Automatically creating config file for zurich_switzerland.mbtiles [INFO] Only a basic preview style will be used. [INFO] See documentation to learn how to create config.json file. Run with --verbose to see the config file here. Starting server Listening at http://[::]:8080/ Startup complete

acalcutt commented 1 year ago

I zipped up the libs I created here if you want to try them https://wifidb.net/demo/maplbre-native/maplibre-native_5.0.1-pre.6_ubuntu_22-04_amd64.gz

The lib folder in this package needs to be placed in tileserver-gl/node_modules/@maplibre/maplibre-gl-native/lib

These were made the way I mentioned in my previous post.

bdmapman commented 1 year ago

Thanks. I will try and let you know. But I think the installation process should be more easier. I was finding for the ubuntu 22.04 solution as I am going to conduct a workshop in the State of the Maps Asia conference that is happening this year in Philippines. But I prepared my docs using 20.04 version already.

acalcutt commented 1 year ago

I agree, and I think maplibre-native and tileserver-gl will both be updated to run on 22.04 eventually. However right now, maplibre-native is built on Ubuntu 20.04 and MacOS-12, so tileserver runs on the same for compatibility. If you are on another OS, the docker version is strongly recommended. Ubuntu 20.04 is still a well supported OS, so I think running on that is fine for now.

If you are building docs right now, it makes sense to recommend Ubuntu 20.04 or the docker version if you need it to work on multiple OS versions with little instruction.

I was trying one other option, which is to tell node-pre-gyp to download binaries from a mirror with something like npm i --mbgl_binary_host_mirror=https://wifidb.net/demo/maplbre-native/mirror/ubuntu_22.04/ but I haven't quite gotten that to work.

I would say both the maplibre-native and tileserver-gl welcome PRs to get this stuff working better.