Ninja Install Fail

I cannot seem to get the rescript rename of bs-platform to install, basically when I do a npm i rescript. I think I may have successfully gotten bs-platform 9.0.1 working, but anything beyond that, no. Here is the gigantic error. I’ve tried with Node 16 and 14, same result. I’m on a Mac 10.15.7 Catalina.

npm ERR! code 1
npm ERR! path /Users/lpq389/Desktop/rescripttesttemplate/rescript-project-template/node_modules/rescript
npm ERR! command failed
npm ERR! command sh -c node scripts/install.js
npm ERR! ninja not compatible? Error: Command failed: "/Users/lpq389/Desktop/rescripttesttemplate/rescript-project-template/node_modules/rescript/darwin/ninja.exe" --version
npm ERR! building ninja
npm ERR! No prebuilt Ninja, building Ninja now
npm ERR! bootstrapping ninja...
npm ERR! warning: A compatible version of re2c (>= 0.11.3) was not found; changes to src/*.in.cc will not affect your build.
npm ERR! wrote build.ninja.
npm ERR! bootstrap complete.  rebuilding...
npm ERR! x .clang-format
npm ERR! x .gitignore
npm ERR! x .travis.yml
npm ERR! x COPYING
npm ERR! x HACKING.md
npm ERR! x README
npm ERR! x RELEASING
npm ERR! x appveyor.yml
npm ERR! x bootstrap.py
npm ERR! x configure.py
npm ERR! x doc/
npm ERR! x doc/README.md
npm ERR! x doc/dblatex.xsl
npm ERR! x doc/docbook.xsl
npm ERR! x doc/doxygen.config
npm ERR! x doc/manual.asciidoc
npm ERR! x doc/style.css
npm ERR! x misc/
npm ERR! x misc/afl-fuzz-tokens/
npm ERR! x misc/afl-fuzz-tokens/kw_build
npm ERR! x misc/afl-fuzz-tokens/kw_default
npm ERR! x misc/afl-fuzz-tokens/kw_include
npm ERR! x misc/afl-fuzz-tokens/kw_pool
npm ERR! x misc/afl-fuzz-tokens/kw_rule
npm ERR! x misc/afl-fuzz-tokens/kw_subninja
npm ERR! x misc/afl-fuzz-tokens/misc_a
npm ERR! x misc/afl-fuzz-tokens/misc_b
npm ERR! x misc/afl-fuzz-tokens/misc_colon
npm ERR! x misc/afl-fuzz-tokens/misc_cont
npm ERR! x misc/afl-fuzz-tokens/misc_dollar
npm ERR! x misc/afl-fuzz-tokens/misc_eq
npm ERR! x misc/afl-fuzz-tokens/misc_indent
npm ERR! x misc/afl-fuzz-tokens/misc_pipe
npm ERR! x misc/afl-fuzz-tokens/misc_pipepipe
npm ERR! x misc/afl-fuzz-tokens/misc_space
npm ERR! x misc/afl-fuzz/
npm ERR! x misc/afl-fuzz/build.ninja
npm ERR! x misc/bash-completion
npm ERR! x misc/ci.py
npm ERR! x misc/inherited-fds.ninja
npm ERR! x misc/long-slow-build.ninja
npm ERR! x misc/measure.py
npm ERR! x misc/ninja-mode.el
npm ERR! x misc/ninja.vim
npm ERR! x misc/ninja_syntax.py
npm ERR! x misc/ninja_syntax_test.py
npm ERR! x misc/output_test.py
npm ERR! x misc/packaging/
npm ERR! x misc/packaging/ninja.spec
npm ERR! x misc/packaging/rpmbuild.sh
npm ERR! x misc/write_fake_manifests.py
npm ERR! x misc/zsh-completion
npm ERR! x snapshot.js
npm ERR! x src/
npm ERR! x src/browse.cc
npm ERR! x src/browse.h
npm ERR! x src/browse.py
npm ERR! x src/build.cc
npm ERR! x src/build.h
npm ERR! x src/build_log.cc
npm ERR! x src/build_log.h
npm ERR! x src/build_log_perftest.cc
npm ERR! x src/build_log_test.cc
npm ERR! x src/build_test.cc
npm ERR! x src/canon_perftest.cc
npm ERR! x src/clean.cc
npm ERR! x src/clean.h
npm ERR! x src/clean_test.cc
npm ERR! x src/clparser.cc
npm ERR! x src/clparser.h
npm ERR! x src/clparser_perftest.cc
npm ERR! x src/clparser_test.cc
npm ERR! x src/debug_flags.cc
npm ERR! x src/debug_flags.h
npm ERR! x src/depfile_parser.cc
npm ERR! x src/depfile_parser.h
npm ERR! x src/depfile_parser.in.cc
npm ERR! x src/depfile_parser_perftest.cc
npm ERR! x src/depfile_parser_test.cc
npm ERR! x src/deps_log.cc
npm ERR! x src/deps_log.h
npm ERR! x src/deps_log_test.cc
npm ERR! x src/disk_interface.cc
npm ERR! x src/disk_interface.h
npm ERR! x src/disk_interface_test.cc
npm ERR! x src/dyndep.cc
npm ERR! x src/dyndep.h
npm ERR! x src/dyndep_parser.cc
npm ERR! x src/dyndep_parser.h
npm ERR! x src/dyndep_parser_test.cc
npm ERR! x src/edit_distance.cc
npm ERR! x src/edit_distance.h
npm ERR! x src/edit_distance_test.cc
npm ERR! x src/eval_env.cc
npm ERR! x src/eval_env.h
npm ERR! x src/exit_status.h
npm ERR! x src/gen_doxygen_mainpage.sh
npm ERR! x src/getopt.c
npm ERR! x src/getopt.h
npm ERR! x src/graph.cc
npm ERR! x src/graph.h
npm ERR! x src/graph_test.cc
npm ERR! x src/graphviz.cc
npm ERR! x src/graphviz.h
npm ERR! x src/hash_collision_bench.cc
npm ERR! x src/hash_map.h
npm ERR! x src/includes_normalize-win32.cc
npm ERR! x src/includes_normalize.h
npm ERR! x src/includes_normalize_test.cc
npm ERR! x src/inline.sh
npm ERR! x src/lexer.cc
npm ERR! x src/lexer.h
npm ERR! x src/lexer.in.cc
npm ERR! x src/lexer_test.cc
npm ERR! x src/line_printer.cc
npm ERR! x src/line_printer.h
npm ERR! x src/manifest_parser.cc
npm ERR! x src/manifest_parser.h
npm ERR! x src/manifest_parser_perftest.cc
npm ERR! x src/manifest_parser_test.cc
npm ERR! x src/metrics.cc
npm ERR! x src/metrics.h
npm ERR! x src/minidump-win32.cc
npm ERR! x src/msvc_helper-win32.cc
npm ERR! x src/msvc_helper.h
npm ERR! x src/msvc_helper_main-win32.cc
npm ERR! x src/msvc_helper_test.cc
npm ERR! x src/ninja.cc
npm ERR! x src/ninja_test.cc
npm ERR! x src/parser.cc
npm ERR! x src/parser.h
npm ERR! x src/state.cc
npm ERR! x src/state.h
npm ERR! x src/state_test.cc
npm ERR! x src/string_piece.h
npm ERR! x src/string_piece_util.cc
npm ERR! x src/string_piece_util.h
npm ERR! x src/string_piece_util_test.cc
npm ERR! x src/subprocess-posix.cc
npm ERR! x src/subprocess-win32.cc
npm ERR! x src/subprocess.h
npm ERR! x src/subprocess_test.cc
npm ERR! x src/test.cc
npm ERR! x src/test.h
npm ERR! x src/timestamp.h
npm ERR! x src/util.cc
npm ERR! x src/util.h
npm ERR! x src/util_test.cc
npm ERR! x src/version.cc
npm ERR! x src/version.h
npm ERR! x src/win32port.h
npm ERR! /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: build/libninja.a(deps_log.o) has no symbols
npm ERR! Traceback (most recent call last):
npm ERR!   File "./configure.py", line 703, in <module>
npm ERR!     subprocess.check_call(rebuild_args)
npm ERR!   File "/Users/lpq389/.pyenv/versions/3.8.1/lib/python3.8/subprocess.py", line 359, in check_call
npm ERR!     retcode = call(*popenargs, **kwargs)
npm ERR!   File "/Users/lpq389/.pyenv/versions/3.8.1/lib/python3.8/subprocess.py", line 340, in call
npm ERR!     with Popen(*popenargs, **kwargs) as p:
npm ERR!   File "/Users/lpq389/.pyenv/versions/3.8.1/lib/python3.8/subprocess.py", line 854, in __init__
npm ERR!     self._execute_child(args, executable, preexec_fn, close_fds,
npm ERR!   File "/Users/lpq389/.pyenv/versions/3.8.1/lib/python3.8/subprocess.py", line 1702, in _execute_child
npm ERR!     raise child_exception_type(errno_num, err_msg, err_filename)
npm ERR! OSError: [Errno 5] Input/output error: './ninja'
npm ERR! node:child_process:747
npm ERR!     throw err;
npm ERR!     ^
npm ERR! 
npm ERR! Error: Command failed: ./configure.py --bootstrap
npm ERR!     at checkExecSyncError (node:child_process:707:11)
npm ERR!     at Object.execSync (node:child_process:744:15)
npm ERR!     at build_ninja (/Users/lpq389/Desktop/rescripttesttemplate/rescript-project-template/node_modules/rescript/scripts/install.js:47:10)
npm ERR!     at provideNinja (/Users/lpq389/Desktop/rescripttesttemplate/rescript-project-template/node_modules/rescript/scripts/install.js:94:3)
npm ERR!     at Object.<anonymous> (/Users/lpq389/Desktop/rescripttesttemplate/rescript-project-template/node_modules/rescript/scripts/install.js:217:1)
npm ERR!     at Module._compile (node:internal/modules/cjs/loader:1109:14)
npm ERR!     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
npm ERR!     at Module.load (node:internal/modules/cjs/loader:989:32)
npm ERR!     at Function.Module._load (node:internal/modules/cjs/loader:829:14)
npm ERR!     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12) {
npm ERR!   status: 1,
npm ERR!   signal: null,
npm ERR!   output: [ null, null, null ],
npm ERR!   pid: 91413,
npm ERR!   stdout: null,
npm ERR!   stderr: null
npm ERR! }

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/lpq389/.npm/_logs/2021-06-06T12_51_00_114Z-debug.log

After some googling, I changed my Python using pyenv from 3.9.0 to 3.5.10, then things worked. wat?

I am considering to get rid of python as a dev dependency when the prebuilt ninja does not work, do you have any idea why downgrade python would work?

created an issue port ninja/config.py to nodejs script · Issue #5179 · rescript-lang/rescript-compiler · GitHub to track this

Naw, I just googled Ninja install issues, and someone mentioned it only worked for “X” version, so I pyenv’d that version, and that seemed to fix it. For regular Python code, no. Python, at least 3, is reasonably forward compatible, like Node is. I don’t recall any of my Python code that I wrote in the past breaking (native, not libraries). Maybe Ninja is using like C level stuff that has OS level deps? Sorry, I’m not too experienced at Python.