Encountering an error trying to install bucklescript on 64-bit Windows


#1

Hi –

Am very new to OCaml/Bucklescript. Was trying to build Bucklescript from source on WIndows 10 following these instructions:

Install From Source, Through NPM/Yarn
Prerequisite: either npm or yarn, plus the standard C toolchain.

git clone https://github.com/bucklescript/bucklescript
cd bucklescript
npm install

This was after installing OCaml following instructions here:

https://fdopen.github.io/opam-repository-mingw/installation/

specifically, this (I installed the 64-bit version):

Graphical Installer
You can try the graphical installer:

32-bit (updated 21. Jan 2019)
64-bit (updated 21. Jan 2019)
The installer will first create a customized cygwin environment and then set up opam and OCaml inside this environment. The setup should be easy and fast this way. However, the installer won’t allow you to set custom options: proxy configuration, select the initial OCaml version to install, etc. (If possible, the 64-bit version of cygwin is installed. The 32-bit version is not longer recommended)

When I run npm install from the new bucklescript folder, I get the following error:

C:\Users\Michael\bucklescript>npm install

bs-platform@5.0.0-dev.2 postinstall C:\Users\Michael\bucklescript
node scripts/install.js

ninja binary is already cached and installed: C:\Users\Michael\bucklescript\lib\ninja.exe
ninja: error: ‘bsc.win32’, needed by ‘bsc.exe’, missing and no known rule to make it
child_process.js:637
throw err;
^

Error: Command failed: C:\Users\Michael\bucklescript\lib\ninja.exe -f copy.win32.ninja
at checkExecSyncError (child_process.js:616:11)
at Object.execFileSync (child_process.js:634:13)
at copyPrebuiltCompilers (C:\Users\Michael\bucklescript\scripts\install.js:217:8)
at Object. (C:\Users\Michael\bucklescript\scripts\install.js:266:5)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bs-platform@5.0.0-dev.2 postinstall: node scripts/install.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bs-platform@5.0.0-dev.2 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Michael\AppData\Roaming\npm-cache_logs\2019-02-13T04_44_18_563Z-debug.log

Does this look familiar to anyone? Any ideas for me?

Thanks,

Mike


#2

Okay. So I tracked it down to the following function in install.js in the bucklescript folder:

function copyPrebuiltCompilers() {
cp.execFileSync(ninja_bin_output,
["-f", “copy” + sys_extension + “.ninja”],
{ cwd: lib_dir, stdio: [0, 1, 2] })
}

this ends up invoking ninja.exe -f copy.win32.ninja and the copy.win32.ninja includes copy.ninja, which in turn has the line

build bsc.exe: cp bsc.win32

which is what is triggering the error. I am on a 64-bit platform and have installed the 64-bit OCaml. Does this mean that Bucklescript will only build in a 32-bit environment?

Not familiar enough (or at all, really) with the Ninja build system to know exactly what is going on here, But I do see that bsc is a javascript file that calls child_process.execFileSync, which is what is triggering the error. From the errors that I included above, this is apparently in a file named child_process.js, but I really don’t know where that is located. And if the problem is indeed 32-bit-ness conflicting with the 64-bitness of my Windows 10 platform, is there anything I can do about this?

If anyone has any insight, I would be most appreciative.

Regards,

Mike


#3

Hey Mike, so I think you don’t need to run the install.js script and instead can simply run ../lib/ninja.exe Inside of the folder jscomp. You might not have ninja.exe there, so you can copy it from vendor/ninja/snapshot/ninja.win.
Calling ninja is how everything is built. Then, to get it ready for a release (and to try your newly modified bsb) you have to run ./ninja.exe inside of the lib folder.

The install script is actually for when the user runs npm install bs-platform, it’ll run the install.js script on postinstall which assumes the compiler is pre-built when you’re windows. Hence the error.