Rescript-compiler: Installing bs-platform globally fails

Created on 21 Sep 2017  ·  11Comments  ·  Source: rescript-lang/rescript-compiler

Hi and thanks a lot for BuckleScript!

I'm on Arch Linux 4.12.10 using NPM 5.3.0.

Installing bs-platform locally for a project works fine but it fails with the -g option:

npm install -g bs-platform

/usr/bin/bsb -> /usr/lib/node_modules/bs-platform/bin/bsb
/usr/bin/bsc -> /usr/lib/node_modules/bs-platform/bin/bsc
/usr/bin/bsrefmt -> /usr/lib/node_modules/bs-platform/bin/bsrefmt

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

Working dir /usr/lib/node_modules/bs-platform
fs.js:773
  return binding.rename(pathModule._makeLong(oldPath),
                 ^

Error: EACCES: permission denied, rename '/usr/lib/node_modules/bs-platform/vendor/ninja-build/ninja.linux64' -> '/usr/lib/node_modules/bs-platform/bin/ninja.exe'
    at Object.fs.renameSync (fs.js:773:18)
    at Object.<anonymous> (/usr/lib/node_modules/bs-platform/scripts/install.js:74:8)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Function.Module.runMain (module.js:665:10)
    at startup (bootstrap_node.js:201:16)
    at bootstrap_node.js:626: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/2017-09-21T20_04_49_693Z-debug.log

The log file's contents:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'install', '-g', 'bs-platform' ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session d99c690f4e343db7
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 304 https://registry.npmjs.org/bs-platform 445ms (from cache)
8 silly pacote tag manifest for bs-platform@latest fetched in 506ms
9 silly install loadIdealTree
10 silly install cloneCurrentTreeToIdealTree
11 silly install loadShrinkwrap
12 silly install loadAllDepsIntoIdealTree
13 silly resolveWithNewModule [email protected] checking installable status
14 silly currentTree lib
15 silly idealTree lib
15 silly idealTree └── [email protected]
16 silly install generateActionsToTake
17 silly diffTrees action count 1
18 silly diffTrees add [email protected]
19 silly decomposeActions action count 8
20 silly decomposeActions fetch [email protected]
21 silly decomposeActions extract [email protected]
22 silly decomposeActions preinstall [email protected]
23 silly decomposeActions build [email protected]
24 silly decomposeActions install [email protected]
25 silly decomposeActions postinstall [email protected]
26 silly decomposeActions finalize [email protected]
27 silly decomposeActions refresh-package-json [email protected]
28 silly install executeActions
29 silly doSerial global-install 8
30 verbose correctMkdir /root/.npm/_locks correctMkdir not in flight; initializing
31 verbose lock using /root/.npm/_locks/staging-a072192f34a17023.lock for /usr/lib/node_modules/.staging
32 silly doParallel extract 8
33 silly extract [email protected]
34 silly doReverseSerial unbuild 8
35 silly doSerial remove 8
36 silly doSerial move 8
37 silly doSerial finalize 8
38 silly finalize /usr/lib/node_modules/bs-platform
39 silly doParallel refresh-package-json 8
40 silly refresh-package-json /usr/lib/node_modules/bs-platform
41 silly doParallel preinstall 8
42 silly preinstall [email protected]
43 info lifecycle [email protected]~preinstall: [email protected]
44 silly doSerial build 8
45 silly build [email protected]
46 info linkStuff [email protected]
47 silly linkStuff [email protected] has /usr/lib/node_modules as its parent node_modules
48 silly linkStuff [email protected] is part of a global install
49 silly linkStuff [email protected] is installed into a global node_modules
50 silly linkStuff [email protected] is installed into the top-level global node_modules
51 verbose linkBins [email protected]
52 verbose linkBins [ { bsb: 'bin/bsb', bsc: 'bin/bsc', bsrefmt: 'bin/bsrefmt' },
52 verbose linkBins   '/usr/bin',
52 verbose linkBins   true ]
53 verbose linkMans [email protected]
54 silly doSerial global-link 8
55 silly doParallel update-linked 8
56 silly doSerial install 8
57 silly install [email protected]
58 info lifecycle [email protected]~install: [email protected]
59 silly doSerial postinstall 8
60 silly postinstall [email protected]
61 info lifecycle [email protected]~postinstall: [email protected]
62 verbose lifecycle [email protected]~postinstall: unsafe-perm in lifecycle false
63 verbose lifecycle [email protected]~postinstall: PATH: /usr/lib/node_modules/npm/bin/node-gyp-bin:/usr/lib/node_modules/bs-platform/node_modules/.bin:/usr/lib/node_modules/.bin:/home/mb/.opam/4.02.3+buckle-master/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
64 verbose lifecycle [email protected]~postinstall: CWD: /usr/lib/node_modules/bs-platform
65 silly lifecycle [email protected]~postinstall: Args: [ '-c', 'node scripts/install.js' ]
66 silly lifecycle [email protected]~postinstall: Returned: code: 1  signal: null
67 info lifecycle [email protected]~postinstall: Failed to exec postinstall script
68 verbose unlock done using /root/.npm/_locks/staging-a072192f34a17023.lock for /usr/lib/node_modules/.staging
69 verbose stack Error: [email protected] postinstall: `node scripts/install.js`
69 verbose stack Exit status 1
69 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/lib/utils/lifecycle.js:289:16)
69 verbose stack     at emitTwo (events.js:125:13)
69 verbose stack     at EventEmitter.emit (events.js:213:7)
69 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/lib/utils/spawn.js:40:14)
69 verbose stack     at emitTwo (events.js:125:13)
69 verbose stack     at ChildProcess.emit (events.js:213:7)
69 verbose stack     at maybeClose (internal/child_process.js:927:16)
69 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
70 verbose pkgid [email protected]
71 verbose cwd /root
72 verbose Linux 4.12.10-1-ARCH
73 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "bs-platform"
74 verbose node v8.5.0
75 verbose npm  v5.3.0
76 error code ELIFECYCLE
77 error errno 1
78 error [email protected] postinstall: `node scripts/install.js`
78 error Exit status 1
79 error Failed at the [email protected] postinstall script.
79 error This is probably not a problem with npm. There is likely additional logging output above.
80 verbose exit [ 1, true ]

Just to make sure that installing globally works in general I executed npm install -g jquery. That worked.

Thanks and keep up your great work!

Install Permissions

Most helpful comment

Thanks for your responses!

You have your global npm config set to install to root instead of a user setup, thus to install an npm package globally you need to sudo in front of it or reconfigure npm for in-user global installs. Not a bucklescript issue though unless bucklescript is calling something as a user even when root. :-)

I should have added that I executed npm install -g bs-platform as root after it failed with the same message when being executed as a regular user.

After following option two of the page @bobzhang mentioned, I fixed this issue:

npm config get prefix yielded /usr, so I decided to change NPM's default directory:

mkdir ~/.npm-global

npm config set prefix '~/.npm-global'

echo "export PATH=~/.npm-global/bin:$PATH" >> ~/.bash_profile

source ~/.bash_profile

Maybe it's indeed a good idea to mention this problem in the FAQs.

All 11 comments

this come from time to time, do you find a work around? maybe we should document it in FAQ
relevant link: https://docs.npmjs.com/getting-started/fixing-npm-permissions

faced the exact same issue today installing bs-platform globally on Ubuntu 17.04. I'm using sudo, and able to install other packages globally. Tried both on npm 5 and npm 3.

update: solved the problem by following the link provided by @bobzhang . Thank you a lot!

@snaumov so which suggestion did you follow in the link? (I don't have a linux box at hand)

Thanks for your responses!

You have your global npm config set to install to root instead of a user setup, thus to install an npm package globally you need to sudo in front of it or reconfigure npm for in-user global installs. Not a bucklescript issue though unless bucklescript is calling something as a user even when root. :-)

I should have added that I executed npm install -g bs-platform as root after it failed with the same message when being executed as a regular user.

After following option two of the page @bobzhang mentioned, I fixed this issue:

npm config get prefix yielded /usr, so I decided to change NPM's default directory:

mkdir ~/.npm-global

npm config set prefix '~/.npm-global'

echo "export PATH=~/.npm-global/bin:$PATH" >> ~/.bash_profile

source ~/.bash_profile

Maybe it's indeed a good idea to mention this problem in the FAQs.

@bobzhang @mb720 Option two (moving npm default directory) helped me as well :)

Same issue on OSX 10.12.6 , node 8.7.0 and npm 5.4.2

I've uninstalled v8.7 and then installed LTS node-v6.11.4.pkg (where is npm 3.10.10).
All OK for npm 3

The same problem is with reason-cli installation:
Can't install with npm 5.3.0

Same issue today on the docker node image 8, node 8.9.3 and npm 5.5.1.

Happens in Docker node image 10: node 10.13.0 and npm 6.4.1, based on Ubuntu.

This seems to be a common issue, would you mind send a PR to the docs?
https://github.com/BuckleScript/bucklescript.github.io/blob/source/docs/installation.md
Is there anything we can improve on our side? thanks

PR sent. This seems to be a general problem, not related to OS or BuckleScript, so I don't know what can be done as yet, but at least now there can be an easy to discover page that gives some suggestions to work around it.

Thanks, merged!

Was this page helpful?
0 / 5 - 0 ratings