Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installing bs-platform globally fails #2051

Closed
mb720 opened this issue Sep 21, 2017 · 11 comments
Closed

Installing bs-platform globally fails #2051

mb720 opened this issue Sep 21, 2017 · 11 comments

Comments

@mb720
Copy link

mb720 commented Sep 21, 2017

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

> bs-platform@1.9.2 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! bs-platform@1.9.2 postinstall: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the bs-platform@1.9.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!     /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 npm@5.3.0
3 info using node@v8.5.0
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 bs-platform@1.9.2 checking installable status
14 silly currentTree lib
15 silly idealTree lib
15 silly idealTree └── bs-platform@1.9.2
16 silly install generateActionsToTake
17 silly diffTrees action count 1
18 silly diffTrees add bs-platform@1.9.2
19 silly decomposeActions action count 8
20 silly decomposeActions fetch bs-platform@1.9.2
21 silly decomposeActions extract bs-platform@1.9.2
22 silly decomposeActions preinstall bs-platform@1.9.2
23 silly decomposeActions build bs-platform@1.9.2
24 silly decomposeActions install bs-platform@1.9.2
25 silly decomposeActions postinstall bs-platform@1.9.2
26 silly decomposeActions finalize bs-platform@1.9.2
27 silly decomposeActions refresh-package-json bs-platform@1.9.2
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 bs-platform@1.9.2
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 bs-platform@1.9.2
43 info lifecycle bs-platform@1.9.2~preinstall: bs-platform@1.9.2
44 silly doSerial build 8
45 silly build bs-platform@1.9.2
46 info linkStuff bs-platform@1.9.2
47 silly linkStuff bs-platform@1.9.2 has /usr/lib/node_modules as its parent node_modules
48 silly linkStuff bs-platform@1.9.2 is part of a global install
49 silly linkStuff bs-platform@1.9.2 is installed into a global node_modules
50 silly linkStuff bs-platform@1.9.2 is installed into the top-level global node_modules
51 verbose linkBins bs-platform@1.9.2
52 verbose linkBins [ { bsb: 'bin/bsb', bsc: 'bin/bsc', bsrefmt: 'bin/bsrefmt' },
52 verbose linkBins   '/usr/bin',
52 verbose linkBins   true ]
53 verbose linkMans bs-platform@1.9.2
54 silly doSerial global-link 8
55 silly doParallel update-linked 8
56 silly doSerial install 8
57 silly install bs-platform@1.9.2
58 info lifecycle bs-platform@1.9.2~install: bs-platform@1.9.2
59 silly doSerial postinstall 8
60 silly postinstall bs-platform@1.9.2
61 info lifecycle bs-platform@1.9.2~postinstall: bs-platform@1.9.2
62 verbose lifecycle bs-platform@1.9.2~postinstall: unsafe-perm in lifecycle false
63 verbose lifecycle bs-platform@1.9.2~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 bs-platform@1.9.2~postinstall: CWD: /usr/lib/node_modules/bs-platform
65 silly lifecycle bs-platform@1.9.2~postinstall: Args: [ '-c', 'node scripts/install.js' ]
66 silly lifecycle bs-platform@1.9.2~postinstall: Returned: code: 1  signal: null
67 info lifecycle bs-platform@1.9.2~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: bs-platform@1.9.2 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 bs-platform@1.9.2
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 bs-platform@1.9.2 postinstall: `node scripts/install.js`
78 error Exit status 1
79 error Failed at the bs-platform@1.9.2 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!

@bobzhang
Copy link
Member

bobzhang commented Sep 22, 2017

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

@snaumov
Copy link

snaumov commented Sep 22, 2017

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!

@bobzhang
Copy link
Member

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

@mb720
Copy link
Author

mb720 commented Sep 22, 2017

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.

@mb720 mb720 closed this as completed Sep 22, 2017
@snaumov
Copy link

snaumov commented Sep 25, 2017

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

@mikowiec
Copy link

mikowiec commented Oct 23, 2017

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

@thiagoarrais
Copy link

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

@nlfiedler
Copy link

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

@bobzhang bobzhang reopened this Nov 23, 2018
@bobzhang
Copy link
Member

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

@nlfiedler
Copy link

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.

@bobzhang
Copy link
Member

Thanks, merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants