Rescript-compiler: `bs-platform` fails to install on npm >= 5.0.0

Created on 4 Jun 2018  路  14Comments  路  Source: rescript-lang/rescript-compiler

Installing bs-platform fails with the following message on npm >= 5.0.0:

[17:07:58] ~/dev/dockerfiles/sandboxes/reasonml [master] 位 docker run -it node:latest /bin/bash -c "npm install -g [email protected] && npm install -g bs-platform"
 /usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
 + [email protected]
 added 250 packages from 135 contributors, removed 317 packages and updated 38 packages in 14.742s
 /usr/local/bin/bsb -> /usr/local/lib/node_modules/bs-platform/lib/bsb
 /usr/local/bin/bsc -> /usr/local/lib/node_modules/bs-platform/lib/bsc
 /usr/local/bin/bsrefmt -> /usr/local/lib/node_modules/bs-platform/lib/bsrefmt

> [email protected] postinstall /usr/local/lib/node_modules/bs-platform
> node scripts/install.js

No working prebuilt compiler
/bin/sh: 1: ocamlc.opt: not found
Build a local version of OCaml compiler, it may take a couple of minutes
touch: cannot touch 's.h': Permission denied
touch: cannot touch 'm.h': Permission denied
touch: cannot touch 'Makefile': Permission denied
./configure: 200: ./configure: cannot create Makefile: Permission denied
./configure: 204: ./configure: cannot create Makefile: Permission denied
./configure: 206: ./configure: cannot create Makefile: Permission denied
./configure: 211: ./configure: cannot create Makefile: Permission denied
./configure: 215: ./configure: cannot create Makefile: Permission denied
./configure: 217: ./configure: cannot create Makefile: Permission denied
./configure: 221: ./configure: cannot create Makefile: Permission denied
mkdir: cannot create directory '/usr/local/lib/node_modules/bs-platform/cg-51': Permission denied
config.guess: cannot create a temporary directory in /usr/local/lib/node_modules/bs-platform
[ERROR!] Cannot guess host type. You must specify one with the -host option.

touch: cannot touch 's.h': Permission denied
touch: cannot touch 'm.h': Permission denied
touch: cannot touch 'Makefile': Permission denied
./configure: 200: ./configure: cannot create Makefile: Permission denied
./configure: 204: ./configure: cannot create Makefile: Permission denied
./configure: 206: ./configure: cannot create Makefile: Permission denied
./configure: 211: ./configure: cannot create Makefile: Permission denied
./configure: 215: ./configure: cannot create Makefile: Permission denied
./configure: 217: ./configure: cannot create Makefile: Permission denied
./configure: 221: ./configure: cannot create Makefile: Permission denied
mkdir: cannot create directory '/usr/local/lib/node_modules/bs-platform/cg-51': Permission denied
config.guess: cannot create a temporary directory in /usr/local/lib/node_modules/bs-platform

Building a local version of the OCaml compiler failed, check the output above for more information. A possible problem is that you don't have a compiler installed.
/usr/local/lib/node_modules/bs-platform/scripts/install.js:111
            throw e;
                        ^

Error: Command failed: /usr/local/lib/node_modules/bs-platform/scripts/buildocaml.sh
touch: cannot touch 's.h': Permission denied
touch: cannot touch 'm.h': Permission denied
touch: cannot touch 'Makefile': Permission denied
./configure: 200: ./configure: cannot create Makefile: Permission denied
./configure: 204: ./configure: cannot create Makefile: Permission denied
./configure: 206: ./configure: cannot create Makefile: Permission denied
./configure: 211: ./configure: cannot create Makefile: Permission denied
./configure: 215: ./configure: cannot create Makefile: Permission denied
./configure: 217: ./configure: cannot create Makefile: Permission denied
./configure: 221: ./configure: cannot create Makefile: Permission denied
mkdir: cannot create directory '/usr/local/lib/node_modules/bs-platform/cg-51': Permission denied
config.guess: cannot create a temporary directory in /usr/local/lib/node_modules/bs-platform

    at checkExecSyncError (child_process.js:603:11)
        at Object.execFileSync (child_process.js:621:13)
            at tryToProvideOCamlCompiler (/usr/local/lib/node_modules/bs-platform/scripts/install.js:106:27)
                at non_windows_npm_release (/usr/local/lib/node_modules/bs-platform/scripts/install.js:156:9)
                    at Object.<anonymous> (/usr/local/lib/node_modules/bs-platform/scripts/install.js:179:5)
                        at Module._compile (internal/modules/cjs/loader.js:702:30)
                            at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
                                at Module.load (internal/modules/cjs/loader.js:612:32)
                                    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
                                        at Function.Module._load (internal/modules/cjs/loader.js:543:3)
                                        npm ERR! code ELIFECYCLE
                                        npm ERR! errno 1
                                        npm ERR! [email protected] postinstall: `node scripts/install.js`
                                        npm ERR! Exit status 1
                                        npm ERR!
                                        npm ERR! Failed at the [email protected] 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!     /root/.npm/_logs/2018-06-04T21_08_50_882Z-debug.log

Using npm 4.0.0 succeeds (docker run -it node:latest /bin/bash -c "npm install -g [email protected] && npm install -g bs-platform").

need feedback

Most helpful comment

sudo npm install -g bs-platform --unsafe-perm
Works for me :smiley_cat:

All 14 comments

touch: cannot touch 's.h': Permission denied
touch: cannot touch 'm.h': Permission denied
touch: cannot touch 'Makefile': Permission denied
./configure: 200: ./configure: cannot create Makefile: Permission denied

this is probably a npm bug (we have hit npm bugs several times), can you try npm lts?

I'm not sure which npm version would be lts, according to their wiki page here they don't have one.

@nickpascucci do you still have such issues with latest npm?

Same thing happening here. Have tried with npm 5.5.1, 5.6.0 (current lts), and 6.1.0 (current latest). I use n to manage node versions.

Installing with npm 4.0.0 does work.

Tried it with npm 6.1.0, still failing. If you have Docker installed, the reproduction step is simple:

docker run -it node:latest /bin/bash -c "npm install -g npm@latest && npm --version && npm install -g bs-platform"

sudo npm install -g bs-platform --unsafe-perm
Works for me :smiley_cat:

I was having all these issues and what worked for me was this:
sudo apt install build-essential
sudo npm install -g bs-platform --unsafe-perm

what worked for me was:

  1. Changing the owner of the global node_modules directory :
    sudo chown $USER:$USER /usr/lib/node_modules
  1. Simply:
    npm install -g bs-platform

It's good that there are workarounds, but none of the above is a solution - running installations with unsafe permissions enabled or chowning global directories shouldn't be necessary.

Agreed! well, they have to figure whats going wrong and fix it!!

Just ran this under my own account:

yarn global add bs-platform

yarn version 1.9.2
node version: v10.8.0
Fedora 28

User is member of groups: wheel docker

Did not work with npm even as root

The yarn approach one way around this, and I had to use that on FreeBSD. BTW, I tried this with the docker node:10 image (node 10.13.0, npm 6.4.1) and it still happens. The --unsafe-perm hack seems to work. Thanks for that.

seems to be fixed in recent versions.

Was this page helpful?
0 / 5 - 0 ratings