nb icon indicating copy to clipboard operation
nb copied to clipboard

Install fails using npm on Centos 8

Open jimu opened this issue 3 years ago • 2 comments

$ sudo npm install -g nb.sh

/usr/local/bin/bookmark -> /usr/local/lib/node_modules/nb.sh/bin/bookmark
/usr/local/bin/nb.sh -> /usr/local/lib/node_modules/nb.sh/nb
/usr/local/bin/nb -> /usr/local/lib/node_modules/nb.sh/nb

> [email protected] postinstall /usr/local/lib/node_modules/nb.sh
> ./nb completions install

mktemp: failed to create directory via template ‘/usr/local/lib/node_modules/nb.sh/tmp.XXXXXXXXXX’: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `./nb completions install`
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/2020-10-08T13_16_41_104Z-debug.log

$ nb
-bash: nb: command not found

Log File

Gist: /root/.npm/_logs/2020-10-08T13_19_25_110Z-debug.log

System/Environment

$bash --version
GNU bash, version 4.4.19(1)-release (x86_64-redhat-linux-gnu)

$ cat /etc/centos-release
CentOS Linux release 8.2.2004 (Core)

$ cat /proc/version
Linux version 4.18.0-147.el8.x86_64 ([email protected]) (gcc version 8.3.1 20190507 (Red Hat 8.3.1-4) (GCC)) #1 SMP Wed Dec 4 21:51:45 UTC 2019

$ npm --version
6.14.8

jimu avatar Oct 08 '20 13:10 jimu

Same error under WSL2 / Ubuntu:

Log output:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/local/bin/npm', 'install', '-g', 'nb.sh' ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session 8fe4b18ee5c5e62d
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 304 https://registry.npmjs.org/nb.sh 482ms (from cache)
8 silly pacote tag manifest for nb.sh@latest fetched in 489ms
9 timing stage:loadCurrentTree Completed in 513ms
10 silly install loadIdealTree
11 silly install cloneCurrentTreeToIdealTree
12 timing stage:loadIdealTree:cloneCurrentTree Completed in 0ms
13 silly install loadShrinkwrap
14 timing stage:loadIdealTree:loadShrinkwrap Completed in 1ms
15 silly install loadAllDepsIntoIdealTree
16 silly resolveWithNewModule [email protected] checking installable status
17 timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 4ms
18 timing stage:loadIdealTree Completed in 6ms
19 silly currentTree lib
20 silly idealTree lib
20 silly idealTree └── [email protected]
21 silly install generateActionsToTake
22 timing stage:generateActionsToTake Completed in 4ms
23 silly diffTrees action count 1
24 silly diffTrees add [email protected]
25 silly decomposeActions action count 8
26 silly decomposeActions fetch [email protected]
27 silly decomposeActions extract [email protected]
28 silly decomposeActions preinstall [email protected]
29 silly decomposeActions build [email protected]
30 silly decomposeActions install [email protected]
31 silly decomposeActions postinstall [email protected]
32 silly decomposeActions finalize [email protected]
33 silly decomposeActions refresh-package-json [email protected]
34 silly install executeActions
35 silly doSerial global-install 8
36 verbose correctMkdir /home/<user>/.npm/_locks correctMkdir not in flight; initializing
37 verbose lock using /home/<user>/.npm/_locks/staging-3a08f0df5026584d.lock for /usr/local/lib/node_modules/.staging
38 silly doParallel extract 1
39 silly extract [email protected]
40 silly tarball trying nb.sh@latest by hash: sha512-9NhP7uI17L89/SRdTf9Z68w6V52USg+8dOxxRGiRZOp0L8RzIPSRPk6jz6itBzur++liu2shln16/blR3n0ZSA==
41 silly extract nb.sh@latest extracted to /usr/local/lib/node_modules/.staging/nb.sh-573d44c8 (55ms)
42 timing action:extract Completed in 57ms
43 silly doReverseSerial unbuild 8
44 silly doSerial remove 8
45 silly doSerial move 8
46 silly doSerial finalize 8
47 silly finalize /usr/local/lib/node_modules/nb.sh
48 timing action:finalize Completed in 3ms
49 silly doParallel refresh-package-json 1
50 silly refresh-package-json /usr/local/lib/node_modules/nb.sh
51 timing action:refresh-package-json Completed in 12ms
52 silly doParallel preinstall 1
53 silly preinstall [email protected]
54 info lifecycle [email protected]~preinstall: [email protected]
55 timing action:preinstall Completed in 1ms
56 silly doSerial build 8
57 silly build [email protected]
58 info linkStuff [email protected]
59 silly linkStuff [email protected] has /usr/local/lib/node_modules as its parent node_modules
60 silly linkStuff [email protected] is part of a global install
61 silly linkStuff [email protected] is installed into a global node_modules
62 silly linkStuff [email protected] is installed into the top-level global node_modules
63 verbose linkBins [ { nb: 'nb', 'nb.sh': 'nb', bookmark: 'bin/bookmark' },
63 verbose linkBins   '/usr/local/bin',
63 verbose linkBins   true ]
64 timing action:build Completed in 3ms
65 silly doSerial global-link 8
66 silly doParallel update-linked 0
67 silly doSerial install 8
68 silly install [email protected]
69 info lifecycle [email protected]~install: [email protected]
70 timing action:install Completed in 0ms
71 silly doSerial postinstall 8
72 silly postinstall [email protected]
73 info lifecycle [email protected]~postinstall: [email protected]
74 verbose lifecycle [email protected]~postinstall: unsafe-perm in lifecycle false
75 verbose lifecycle [email protected]~postinstall: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/usr/local/lib/node_modules/nb.sh/node_modules/.bin:/usr/local/lib/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
76 verbose lifecycle [email protected]~postinstall: CWD: /usr/local/lib/node_modules/nb.sh
77 silly lifecycle [email protected]~postinstall: Args: [ '-c', './nb completions install' ]
78 silly lifecycle [email protected]~postinstall: Returned: code: 1  signal: null
79 info lifecycle [email protected]~postinstall: Failed to exec postinstall script
80 timing action:postinstall Completed in 299ms
81 verbose unlock done using /home/<user>/.npm/_locks/staging-3a08f0df5026584d.lock for /usr/local/lib/node_modules/.staging
82 timing stage:rollbackFailedOptional Completed in 18ms
83 timing stage:runTopLevelLifecycles Completed in 922ms
84 verbose stack Error: [email protected] postinstall: `./nb completions install`
84 verbose stack Exit status 1
84 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
84 verbose stack     at emitTwo (events.js:126:13)
84 verbose stack     at EventEmitter.emit (events.js:214:7)
84 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
84 verbose stack     at emitTwo (events.js:126:13)
84 verbose stack     at ChildProcess.emit (events.js:214:7)
84 verbose stack     at maybeClose (internal/child_process.js:925:16)
84 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
85 verbose pkgid [email protected]
86 verbose cwd /mnt/c/sources
87 verbose Linux 4.19.128-microsoft-standard
88 verbose argv "/usr/bin/node" "/usr/local/bin/npm" "install" "-g" "nb.sh"
89 verbose node v8.10.0
90 verbose npm  v6.14.8
91 error code ELIFECYCLE
92 error errno 1
93 error [email protected] postinstall: `./nb completions install`
93 error Exit status 1
94 error Failed at the [email protected] postinstall script.
94 error This is probably not a problem with npm. There is likely additional logging output above.
95 verbose exit [ 1, true ]

mstormo avatar Oct 09 '20 20:10 mstormo

Thanks for the information! It looks like npm changes the tmp directory to its current working directory in some cases, which then causes an error when nb calls mktemp while trying to install completions in the postinstall hook. I'm still trying to find a solution, but in the interim removed the completion postinstall hook so it should install successfully as of version 5.5.7.

To install the completions after installing with npm, run (maybe with sudo): nb completions install

I'm going to leave this issue open for the moment while I continue looking into reenabling the postinstall hook.

xwmx avatar Oct 10 '20 17:10 xwmx