mmomtchev / node-gdal-async

Node.js bindings for GDAL (Geospatial Data Abstraction Library) with full async support
https://mmomtchev.github.io/node-gdal-async/
Apache License 2.0
133 stars 26 forks source link

Failing to install M1 mac when building from source #66

Closed alexcroox closed 1 year ago

alexcroox commented 1 year ago

I have a new M1 Mac as my previous one died, I had this working on my old one but am really struggling on this new machine (same setup). I've poured through the logs but can't work out what I'm missing to cause the error, can you shed any light?

➜  exchange git:(main) ✗ node -v
v16.19.0
➜  exchange git:(main) ✗ npm -v
8.19.3
➜  exchange git:(main) ✗ gdal-config --version
3.6.2
➜  exchange git:(main) ✗ npm install gdal-async --no-save --build-from-source --shared_gdal
npm ERR! code 1
npm ERR! path /Users/alex/Projects/exchange/node_modules/gdal-async
npm ERR! command failed
npm ERR! command sh -c -- node-pre-gyp install --fallback-to-build -j max && echo 'I am currently unemployed and looking for work. Please, consider hiring me if you like and use gdal-async. Check https://github.com/mmomtchev to what I do and what is my current situation.'
npm ERR! CXX(target) Release/obj.target/gdal/src/utils/typed_array.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/utils/string_list.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/utils/number_list.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/utils/warp_options.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/utils/ptr_manager.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/node_gdal.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/async.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/gdal_common.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/gdal_dataset.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/gdal_driver.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/gdal_rasterband.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/gdal_group.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/gdal_mdarray.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/gdal_dimension.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/gdal_attribute.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/gdal_majorobject.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/gdal_feature.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/gdal_feature_defn.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/gdal_field_defn.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/geometry/gdal_geometry.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/geometry/gdal_point.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/geometry/gdal_simplecurve.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/geometry/gdal_compoundcurve.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/geometry/gdal_linestring.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/geometry/gdal_circularstring.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/geometry/gdal_linearring.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/geometry/gdal_polygon.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/geometry/gdal_geometrycollection.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/geometry/gdal_multipoint.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/geometry/gdal_multilinestring.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/geometry/gdal_multicurve.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/geometry/gdal_multipolygon.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/gdal_layer.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/gdal_coordinate_transformation.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/gdal_spatial_reference.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/gdal_warper.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/gdal_algorithms.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/gdal_memfile.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/gdal_utils.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/gdal_fs.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/collections/dataset_bands.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/collections/dataset_layers.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/collections/layer_features.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/collections/layer_fields.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/collections/group_groups.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/collections/group_arrays.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/collections/group_attributes.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/collections/group_dimensions.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/collections/array_dimensions.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/collections/array_attributes.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/collections/feature_fields.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/collections/feature_defn_fields.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/collections/geometry_collection_children.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/collections/polygon_rings.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/collections/linestring_points.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/collections/compound_curves.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/collections/rasterband_overviews.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/collections/rasterband_pixels.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/collections/gdal_drivers.o
npm ERR!   CXX(target) Release/obj.target/gdal/src/collections/colortable.o
npm ERR!   SOLINK_MODULE(target) Release/gdal.node
npm ERR!   ACTION binding_gyp_action_after_build_target_yatag ../lib/index.d.ts
npm ERR!   COPY /Users/alex/Projects/exchange/node_modules/gdal-async/lib/binding/node-v93-darwin-arm64/gdal.node
npm ERR!
npm ERR! > gdal-async@3.6.2 yatag
npm ERR! > npx yatag
npm ERR!
npm ERR! Failed to execute '/Users/alex/.nvm/versions/node/v16.19.0/bin/node /Users/alex/.nvm/versions/node/v16.19.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --jobs=max --module=/Users/alex/Projects/exchange/node_modules/gdal-async/lib/binding/node-v93-darwin-arm64/gdal.node --module_name=gdal --module_path=/Users/alex/Projects/exchange/node_modules/gdal-async/lib/binding/node-v93-darwin-arm64 --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using node-pre-gyp@1.0.9
npm ERR! node-pre-gyp info using node@16.19.0 | darwin | arm64
npm ERR! node-pre-gyp info build requesting source compile
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.1.0
npm ERR! gyp info using node@16.19.0 | darwin | arm64
npm ERR! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.1.0
npm ERR! gyp info using node@16.19.0 | darwin | arm64
npm ERR! gyp info find Python using Python version 3.11.2 found at "/opt/homebrew/opt/python@3.11/bin/python3.11"
npm ERR! gyp info spawn /opt/homebrew/opt/python@3.11/bin/python3.11
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/Users/alex/.nvm/versions/node/v16.19.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/alex/Projects/exchange/node_modules/gdal-async/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/alex/Projects/exchange/node_modules/gdal-async/common.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/alex/.nvm/versions/node/v16.19.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/alex/Library/Caches/node-gyp/16.19.0/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/Users/alex/Library/Caches/node-gyp/16.19.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/Users/alex/.nvm/versions/node/v16.19.0/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/alex/Library/Caches/node-gyp/16.19.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/alex/Projects/exchange/node_modules/gdal-async',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.1.0
npm ERR! gyp info using node@16.19.0 | darwin | arm64
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build', '--jobs', 10 ]
npm ERR! ld: warning: dylib (/opt/homebrew/Cellar/gdal/3.6.2_2/lib/libgdal.dylib) was built for newer macOS version (13.0) than being linked (11.0)
npm ERR! sh: yatag: command not found
npm ERR! make: *** [../lib/index.d.ts] Error 127
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/Users/alex/.nvm/versions/node/v16.19.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:201:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)
npm ERR! gyp ERR! System Darwin 22.3.0
npm ERR! gyp ERR! command "/Users/alex/.nvm/versions/node/v16.19.0/bin/node" "/Users/alex/.nvm/versions/node/v16.19.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--jobs=max" "--module=/Users/alex/Projects/exchange/node_modules/gdal-async/lib/binding/node-v93-darwin-arm64/gdal.node" "--module_name=gdal" "--module_path=/Users/alex/Projects/exchange/node_modules/gdal-async/lib/binding/node-v93-darwin-arm64" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v93"
npm ERR! gyp ERR! cwd /Users/alex/Projects/exchange/node_modules/gdal-async
npm ERR! gyp ERR! node -v v16.19.0
npm ERR! gyp ERR! node-gyp -v v9.1.0
npm ERR! gyp ERR! not ok
npm ERR! node-pre-gyp ERR! build error
npm ERR! node-pre-gyp ERR! stack Error: Failed to execute '/Users/alex/.nvm/versions/node/v16.19.0/bin/node /Users/alex/.nvm/versions/node/v16.19.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --jobs=max --module=/Users/alex/Projects/exchange/node_modules/gdal-async/lib/binding/node-v93-darwin-arm64/gdal.node --module_name=gdal --module_path=/Users/alex/Projects/exchange/node_modules/gdal-async/lib/binding/node-v93-darwin-arm64 --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/alex/Projects/exchange/node_modules/gdal-async/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1100:16)
npm ERR! node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
npm ERR! node-pre-gyp ERR! System Darwin 22.3.0
npm ERR! node-pre-gyp ERR! command "/Users/alex/.nvm/versions/node/v16.19.0/bin/node" "/Users/alex/Projects/exchange/node_modules/gdal-async/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "-j" "max"
npm ERR! node-pre-gyp ERR! cwd /Users/alex/Projects/exchange/node_modules/gdal-async
npm ERR! node-pre-gyp ERR! node -v v16.19.0
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.9
npm ERR! node-pre-gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/alex/.npm/_logs/2023-02-16T10_48_42_731Z-debug-0.log
alexcroox commented 1 year ago

OK found a fix:

npm install yatag -g