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

Failed to install native modules with Node installed via Snap #3

Open
leafac opened this issue Feb 25, 2021 · 6 comments
Open

Failed to install native modules with Node installed via Snap #3

leafac opened this issue Feb 25, 2021 · 6 comments

Comments

@leafac
Copy link

leafac commented Feb 25, 2021

I installed the node snap from channel 15/stable using the Ubuntu Software GUI. I have Python and the build-essential apt package installed, so I have a working setup for native modules in Node.js. Yet, the installation of native modules (for example, sharp and better-sqlite3) failed with no helpful error messages (not even in the log files); it just says that it failed to run the installation scripts.

I tried the deb packages and they worked, so it must have to do with the Snap.

What could be going on?

@rvagg
Copy link
Member

rvagg commented Feb 26, 2021

Maybe you could share your log messages and we can see? And also details on Linux distribution (plain Ubuntu?) and version would be informative.

There is a problem with snaps building addons in that the snap has its own toolchain and set of libraries, so when running node you're not using your standard system libraries, but those that are inside the snap isolation environment. This is just how snaps work and lets them be consistent across OSs and versions, but it leads to dynamic library issues if things don't line up quite right. Generally if you have a complex environment and want to do addons then you're probably better off not using the snap.

@leafac
Copy link
Author

leafac commented Mar 8, 2021

Maybe you could share your log messages and we can see? And also details on Linux distribution (plain Ubuntu?) and version would be informative.

Isn’t it annoying when people open an issue saying “it doesn’t work,” but don’t include the error message? 😛

I’m sorry about that. I didn’t include the error messages because I wasn’t in front of the Ubuntu machine when I opened the issue. Also, I don’t think the error messages are very helpful in this case.

Here’s what’s going on:

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.10
Release:	20.10
Codename:	groovy

$ uname -a
Linux leafac-ubuntu 5.8.0-44-generic #50-Ubuntu SMP Tue Feb 9 06:29:41 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

I have the build tools necessary to install native Node.js extensions (I installed the build-essential package with apt):

$ gcc --version
gcc (Homebrew GCC 5.5.0_7) 5.5.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ make --version
GNU Make 4.3
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

$ python3 --version
Python 3.8.6

I installed the Node.js snap with the Ubuntu Software application. I chose Source 15/stable.

If I try to install a package that has no native part, it works fine:

$ node --version
v15.11.0

$ npm --version
7.6.0

$ npm i @leafac/html

added 2 packages, and audited 3 packages in 3s

found 0 vulnerabilities

This proves that the installation succeeded. But then, if I try to install sharp, which is a native module:

$ npm i sharp
npm ERR! code 1
npm ERR! path /tmp/node-snap/node_modules/sharp
npm ERR! command failed
npm ERR! command sh -c (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/leafac/.npm/_logs/2021-03-08T10_34_27_422Z-debug.log

And the contents of the log are the following:

$ cat /home/leafac/.npm/_logs/2021-03-08T10_34_27_422Z-debug.log
0 verbose cli [
0 verbose cli   '/snap/node/3836/bin/node',
0 verbose cli   '/home/linuxbrew/.linuxbrew/bin/npm',
0 verbose cli   'i',
0 verbose cli   'sharp'
0 verbose cli ]
1 info using [email protected]
2 info using [email protected]
3 timing config:load:defaults Completed in 1ms
4 timing config:load:file:/home/linuxbrew/.linuxbrew/lib/node_modules/npm/npmrc Completed in 10ms
5 timing config:load:builtin Completed in 10ms
6 timing config:load:cli Completed in 2ms
7 timing config:load:env Completed in 0ms
8 timing config:load:file:/tmp/node-snap/.npmrc Completed in 0ms
9 timing config:load:project Completed in 1ms
10 timing config:load:file:/home/leafac/.npmrc Completed in 0ms
11 timing config:load:user Completed in 0ms
12 timing config:load:file:/home/linuxbrew/.linuxbrew/etc/npmrc Completed in 0ms
13 timing config:load:global Completed in 1ms
14 timing config:load:cafile Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:setUserAgent Completed in 1ms
17 timing config:load:setEnvs Completed in 0ms
18 timing config:load Completed in 16ms
19 verbose npm-session d2a8ac6480e876a4
20 timing npm:load Completed in 25ms
21 timing arborist:ctor Completed in 1ms
22 timing arborist:ctor Completed in 0ms
23 timing idealTree:init Completed in 14ms
24 timing idealTree:userRequests Completed in 2ms
25 silly idealTree buildDeps
26 silly fetch manifest sharp@*
27 http fetch GET 304 https://registry.npmjs.org/sharp 804ms (from cache)
28 silly placeDep ROOT [email protected] OK for:  want: *
29 silly fetch manifest array-flatten@^3.0.0
30 silly fetch manifest color@^3.1.3
31 silly fetch manifest detect-libc@^1.0.3
32 silly fetch manifest node-addon-api@^3.1.0
33 silly fetch manifest npmlog@^4.1.2
34 silly fetch manifest prebuild-install@^6.0.1
35 silly fetch manifest semver@^7.3.4
36 silly fetch manifest simple-get@^4.0.0
37 silly fetch manifest tar-fs@^2.1.1
38 silly fetch manifest tunnel-agent@^0.6.0
39 http fetch GET 304 https://registry.npmjs.org/semver 368ms (from cache)
40 http fetch GET 304 https://registry.npmjs.org/array-flatten 397ms (from cache)
41 http fetch GET 304 https://registry.npmjs.org/detect-libc 414ms (from cache)
42 http fetch GET 304 https://registry.npmjs.org/tar-fs 419ms (from cache)
43 http fetch GET 304 https://registry.npmjs.org/node-addon-api 440ms (from cache)
44 http fetch GET 304 https://registry.npmjs.org/prebuild-install 443ms (from cache)
45 http fetch GET 304 https://registry.npmjs.org/simple-get 448ms (from cache)
46 http fetch GET 304 https://registry.npmjs.org/tunnel-agent 494ms (from cache)
47 http fetch GET 304 https://registry.npmjs.org/npmlog 508ms (from cache)
48 http fetch GET 304 https://registry.npmjs.org/color 594ms (from cache)
49 timing idealTree:#root Completed in 1421ms
50 silly placeDep ROOT [email protected] OK for: [email protected] want: ^3.0.0
51 silly placeDep ROOT [email protected] OK for: [email protected] want: ^3.1.3
52 silly placeDep ROOT [email protected] OK for: [email protected] want: ^1.0.3
53 silly placeDep ROOT [email protected] OK for: [email protected] want: ^3.1.0
54 silly placeDep ROOT [email protected] OK for: [email protected] want: ^4.1.2
55 silly placeDep ROOT [email protected] OK for: [email protected] want: ^6.0.1
56 silly placeDep ROOT [email protected] OK for: [email protected] want: ^7.3.4
57 silly placeDep ROOT [email protected] OK for: [email protected] want: ^4.0.0
58 silly placeDep ROOT [email protected] OK for: [email protected] want: ^2.1.1
59 silly placeDep ROOT [email protected] OK for: [email protected] want: ^0.6.0
60 silly fetch manifest color-convert@^1.9.1
61 silly fetch manifest color-string@^1.5.4
62 silly fetch manifest are-we-there-yet@~1.1.2
63 silly fetch manifest console-control-strings@~1.1.0
64 silly fetch manifest gauge@~2.7.3
65 silly fetch manifest set-blocking@~2.0.0
66 silly fetch manifest expand-template@^2.0.3
67 silly fetch manifest [email protected]
68 silly fetch manifest minimist@^1.2.3
69 silly fetch manifest mkdirp-classic@^0.5.3
70 silly fetch manifest napi-build-utils@^1.0.1
71 silly fetch manifest node-abi@^2.7.0
72 silly fetch manifest noop-logger@^0.1.1
73 silly fetch manifest pump@^3.0.0
74 silly fetch manifest rc@^1.2.7
75 silly fetch manifest simple-get@^3.0.3
76 silly fetch manifest which-pm-runs@^1.0.0
77 silly fetch manifest lru-cache@^6.0.0
78 silly fetch manifest decompress-response@^6.0.0
79 silly fetch manifest once@^1.3.1
80 silly fetch manifest simple-concat@^1.0.0
81 silly fetch manifest chownr@^1.1.1
82 silly fetch manifest mkdirp-classic@^0.5.2
83 silly fetch manifest tar-stream@^2.1.4
84 silly fetch manifest safe-buffer@^5.0.1
85 http fetch GET 200 https://registry.npmjs.org/color-string 117ms
86 http fetch GET 304 https://registry.npmjs.org/console-control-strings 128ms (from cache)
87 http fetch GET 304 https://registry.npmjs.org/github-from-package 127ms (from cache)
88 http fetch GET 304 https://registry.npmjs.org/color-convert 148ms (from cache)
89 http fetch GET 304 https://registry.npmjs.org/decompress-response 157ms (from cache)
90 http fetch GET 304 https://registry.npmjs.org/pump 177ms (from cache)
91 http fetch GET 304 https://registry.npmjs.org/gauge 197ms (from cache)
92 http fetch GET 304 https://registry.npmjs.org/mkdirp-classic 191ms (from cache)
93 http fetch GET 304 https://registry.npmjs.org/expand-template 197ms (from cache)
94 http fetch GET 304 https://registry.npmjs.org/lru-cache 194ms (from cache)
95 http fetch GET 304 https://registry.npmjs.org/minimist 223ms (from cache)
96 http fetch GET 304 https://registry.npmjs.org/napi-build-utils 223ms (from cache)
97 http fetch GET 304 https://registry.npmjs.org/rc 227ms (from cache)
98 http fetch GET 200 https://registry.npmjs.org/node-abi 234ms
99 http fetch GET 304 https://registry.npmjs.org/noop-logger 236ms (from cache)
100 http fetch GET 304 https://registry.npmjs.org/chownr 223ms (from cache)
101 http fetch GET 304 https://registry.npmjs.org/set-blocking 263ms (from cache)
102 http fetch GET 304 https://registry.npmjs.org/which-pm-runs 250ms (from cache)
103 http fetch GET 304 https://registry.npmjs.org/safe-buffer 238ms (from cache)
104 http fetch GET 304 https://registry.npmjs.org/are-we-there-yet 274ms (from cache)
105 http fetch GET 304 https://registry.npmjs.org/tar-stream 242ms (from cache)
106 http fetch GET 304 https://registry.npmjs.org/once 247ms (from cache)
107 http fetch GET 304 https://registry.npmjs.org/simple-concat 250ms (from cache)
108 timing idealTree:node_modules/sharp Completed in 397ms
109 timing idealTree:node_modules/array-flatten Completed in 0ms
110 silly placeDep ROOT [email protected] OK for: [email protected] want: ^1.9.1
111 silly placeDep ROOT [email protected] OK for: [email protected] want: ^1.5.4
112 silly fetch manifest [email protected]
113 silly fetch manifest color-name@^1.0.0
114 silly fetch manifest simple-swizzle@^0.2.2
115 http fetch GET 304 https://registry.npmjs.org/color-name 56ms (from cache)
116 http fetch GET 304 https://registry.npmjs.org/simple-swizzle 56ms (from cache)
117 timing idealTree:node_modules/color Completed in 62ms
118 silly placeDep ROOT [email protected] OK for: [email protected] want: 1.1.3
119 timing idealTree:node_modules/color-convert Completed in 1ms
120 timing idealTree:node_modules/color-name Completed in 0ms
121 silly placeDep ROOT [email protected] OK for: [email protected] want: ^0.2.2
122 silly fetch manifest is-arrayish@^0.3.1
123 http fetch GET 304 https://registry.npmjs.org/is-arrayish 48ms (from cache)
124 timing idealTree:node_modules/color-string Completed in 51ms
125 timing idealTree:node_modules/detect-libc Completed in 0ms
126 timing idealTree:node_modules/node-addon-api Completed in 0ms
127 silly placeDep ROOT [email protected] OK for: [email protected] want: ~1.1.2
128 silly placeDep ROOT [email protected] OK for: [email protected] want: ~1.1.0
129 silly placeDep ROOT [email protected] OK for: [email protected] want: ~2.7.3
130 silly placeDep ROOT [email protected] OK for: [email protected] want: ~2.0.0
131 silly fetch manifest delegates@^1.0.0
132 silly fetch manifest readable-stream@^2.0.6
133 silly fetch manifest aproba@^1.0.3
134 silly fetch manifest has-unicode@^2.0.0
135 silly fetch manifest object-assign@^4.1.0
136 silly fetch manifest signal-exit@^3.0.0
137 silly fetch manifest string-width@^1.0.1
138 silly fetch manifest strip-ansi@^3.0.1
139 silly fetch manifest wide-align@^1.1.0
140 http fetch GET 304 https://registry.npmjs.org/readable-stream 73ms (from cache)
141 http fetch GET 304 https://registry.npmjs.org/wide-align 81ms (from cache)
142 http fetch GET 304 https://registry.npmjs.org/delegates 89ms (from cache)
143 http fetch GET 304 https://registry.npmjs.org/strip-ansi 86ms (from cache)
144 http fetch GET 304 https://registry.npmjs.org/aproba 93ms (from cache)
145 http fetch GET 304 https://registry.npmjs.org/has-unicode 95ms (from cache)
146 http fetch GET 304 https://registry.npmjs.org/string-width 96ms (from cache)
147 http fetch GET 304 https://registry.npmjs.org/object-assign 100ms (from cache)
148 http fetch GET 304 https://registry.npmjs.org/signal-exit 144ms (from cache)
149 timing idealTree:node_modules/npmlog Completed in 154ms
150 silly placeDep ROOT [email protected] OK for: [email protected] want: ^1.0.0
151 silly placeDep ROOT [email protected] OK for: [email protected] want: ^2.0.6
152 silly fetch manifest core-util-is@~1.0.0
153 silly fetch manifest inherits@~2.0.3
154 silly fetch manifest isarray@~1.0.0
155 silly fetch manifest process-nextick-args@~2.0.0
156 silly fetch manifest safe-buffer@~5.1.1
157 silly fetch manifest string_decoder@~1.1.1
158 silly fetch manifest util-deprecate@~1.0.1
159 http fetch GET 304 https://registry.npmjs.org/string_decoder 73ms (from cache)
160 http fetch GET 304 https://registry.npmjs.org/inherits 81ms (from cache)
161 http fetch GET 304 https://registry.npmjs.org/isarray 81ms (from cache)
162 http fetch GET 304 https://registry.npmjs.org/util-deprecate 81ms (from cache)
163 http fetch GET 304 https://registry.npmjs.org/process-nextick-args 87ms (from cache)
164 http fetch GET 304 https://registry.npmjs.org/core-util-is 103ms (from cache)
165 timing idealTree:node_modules/are-we-there-yet Completed in 107ms
166 timing idealTree:node_modules/console-control-strings Completed in 0ms
167 timing idealTree:node_modules/delegates Completed in 0ms
168 silly placeDep ROOT [email protected] OK for: [email protected] want: ^1.0.3
169 silly placeDep ROOT [email protected] OK for: [email protected] want: ^2.0.0
170 silly placeDep ROOT [email protected] OK for: [email protected] want: ^4.1.0
171 silly placeDep ROOT [email protected] OK for: [email protected] want: ^3.0.0
172 silly placeDep ROOT [email protected] OK for: [email protected] want: ^1.0.1
173 silly placeDep ROOT [email protected] OK for: [email protected] want: ^3.0.1
174 silly placeDep ROOT [email protected] OK for: [email protected] want: ^1.1.0
175 silly fetch manifest code-point-at@^1.0.0
176 silly fetch manifest is-fullwidth-code-point@^1.0.0
177 silly fetch manifest ansi-regex@^2.0.0
178 http fetch GET 304 https://registry.npmjs.org/ansi-regex 48ms (from cache)
179 http fetch GET 304 https://registry.npmjs.org/code-point-at 55ms (from cache)
180 http fetch GET 304 https://registry.npmjs.org/is-fullwidth-code-point 60ms (from cache)
181 timing idealTree:node_modules/gauge Completed in 71ms
182 timing idealTree:node_modules/aproba Completed in 0ms
183 timing idealTree:node_modules/has-unicode Completed in 0ms
184 timing idealTree:node_modules/object-assign Completed in 0ms
185 silly placeDep ROOT [email protected] OK for: [email protected] want: ^2.0.3
186 silly placeDep ROOT [email protected] OK for: [email protected] want: 0.0.0
187 silly placeDep ROOT [email protected] OK for: [email protected] want: ^1.2.3
188 silly placeDep ROOT [email protected] OK for: [email protected] want: ^0.5.3
189 silly placeDep ROOT [email protected] OK for: [email protected] want: ^1.0.1
190 silly placeDep ROOT [email protected] OK for: [email protected] want: ^2.7.0
191 silly placeDep ROOT [email protected] OK for: [email protected] want: ^0.1.1
192 silly placeDep ROOT [email protected] OK for: [email protected] want: ^3.0.0
193 silly placeDep ROOT [email protected] OK for: [email protected] want: ^1.2.7
194 silly placeDep node_modules/prebuild-install [email protected] OK for: [email protected] want: ^3.0.3
195 silly placeDep ROOT [email protected] OK for: [email protected] want: ^1.0.0
196 silly fetch manifest semver@^5.4.1
197 silly fetch manifest end-of-stream@^1.1.0
198 silly fetch manifest deep-extend@^0.6.0
199 silly fetch manifest ini@~1.3.0
200 silly fetch manifest strip-json-comments@~2.0.1
201 silly fetch manifest decompress-response@^4.2.0
202 http fetch GET 304 https://registry.npmjs.org/strip-json-comments 74ms (from cache)
203 http fetch GET 304 https://registry.npmjs.org/ini 84ms (from cache)
204 http fetch GET 304 https://registry.npmjs.org/deep-extend 93ms (from cache)
205 http fetch GET 304 https://registry.npmjs.org/end-of-stream 104ms (from cache)
206 timing idealTree:node_modules/prebuild-install Completed in 123ms
207 timing idealTree:node_modules/expand-template Completed in 0ms
208 timing idealTree:node_modules/github-from-package Completed in 0ms
209 timing idealTree:node_modules/minimist Completed in 0ms
210 timing idealTree:node_modules/mkdirp-classic Completed in 0ms
211 timing idealTree:node_modules/napi-build-utils Completed in 0ms
212 silly placeDep node_modules/node-abi [email protected] OK for: [email protected] want: ^5.4.1
213 timing idealTree:node_modules/node-abi Completed in 2ms
214 timing idealTree:node_modules/noop-logger Completed in 0ms
215 silly placeDep ROOT [email protected] OK for: [email protected] want: ^1.1.0
216 silly placeDep ROOT [email protected] OK for: [email protected] want: ^1.3.1
217 silly fetch manifest wrappy@1
218 http fetch GET 304 https://registry.npmjs.org/wrappy 94ms (from cache)
219 timing idealTree:node_modules/pump Completed in 100ms
220 timing idealTree:node_modules/end-of-stream Completed in 0ms
221 silly placeDep ROOT [email protected] OK for: [email protected] want: 1
222 timing idealTree:node_modules/once Completed in 1ms
223 silly placeDep ROOT [email protected] OK for: [email protected] want: ^0.6.0
224 silly placeDep ROOT [email protected] OK for: [email protected] want: ~1.3.0
225 silly placeDep ROOT [email protected] OK for: [email protected] want: ~2.0.1
226 timing idealTree:node_modules/rc Completed in 3ms
227 timing idealTree:node_modules/deep-extend Completed in 0ms
228 timing idealTree:node_modules/ini Completed in 0ms
229 silly placeDep ROOT [email protected] OK for: [email protected] want: ~1.0.0
230 silly placeDep ROOT [email protected] OK for: [email protected] want: ~2.0.3
231 silly placeDep ROOT [email protected] OK for: [email protected] want: ~1.0.0
232 silly placeDep ROOT [email protected] OK for: [email protected] want: ~2.0.0
233 silly placeDep ROOT [email protected] OK for: [email protected] want: ~5.1.1
234 silly placeDep ROOT [email protected] OK for: [email protected] want: ~1.1.1
235 silly placeDep ROOT [email protected] OK for: [email protected] want: ~1.0.1
236 timing idealTree:node_modules/readable-stream Completed in 6ms
237 timing idealTree:node_modules/core-util-is Completed in 0ms
238 timing idealTree:node_modules/inherits Completed in 0ms
239 timing idealTree:node_modules/isarray Completed in 0ms
240 timing idealTree:node_modules/process-nextick-args Completed in 0ms
241 timing idealTree:node_modules/safe-buffer Completed in 0ms
242 silly placeDep ROOT [email protected] OK for: [email protected] want: ^6.0.0
243 silly fetch manifest yallist@^4.0.0
244 http fetch GET 304 https://registry.npmjs.org/yallist 50ms (from cache)
245 timing idealTree:node_modules/semver Completed in 53ms
246 silly placeDep ROOT [email protected] OK for: [email protected] want: ^4.0.0
247 timing idealTree:node_modules/lru-cache Completed in 2ms
248 timing idealTree:node_modules/set-blocking Completed in 0ms
249 timing idealTree:node_modules/signal-exit Completed in 0ms
250 silly placeDep ROOT [email protected] OK for: [email protected] want: ^6.0.0
251 silly placeDep ROOT [email protected] OK for: [email protected] want: ^1.0.0
252 silly fetch manifest mimic-response@^3.1.0
253 http fetch GET 304 https://registry.npmjs.org/mimic-response 90ms (from cache)
254 timing idealTree:node_modules/simple-get Completed in 96ms
255 silly placeDep ROOT [email protected] OK for: [email protected] want: ^3.1.0
256 timing idealTree:node_modules/decompress-response Completed in 4ms
257 timing idealTree:node_modules/mimic-response Completed in 0ms
258 timing idealTree:node_modules/simple-concat Completed in 0ms
259 silly placeDep ROOT [email protected] OK for: [email protected] want: ^0.3.1
260 timing idealTree:node_modules/simple-swizzle Completed in 1ms
261 timing idealTree:node_modules/is-arrayish Completed in 0ms
262 timing idealTree:node_modules/string_decoder Completed in 0ms
263 silly placeDep ROOT [email protected] OK for: [email protected] want: ^1.0.0
264 silly placeDep ROOT [email protected] OK for: [email protected] want: ^1.0.0
265 silly fetch manifest number-is-nan@^1.0.0
266 http fetch GET 304 https://registry.npmjs.org/number-is-nan 71ms (from cache)
267 timing idealTree:node_modules/string-width Completed in 78ms
268 timing idealTree:node_modules/code-point-at Completed in 0ms
269 silly placeDep ROOT [email protected] OK for: [email protected] want: ^1.0.0
270 timing idealTree:node_modules/is-fullwidth-code-point Completed in 4ms
271 timing idealTree:node_modules/number-is-nan Completed in 0ms
272 silly placeDep ROOT [email protected] OK for: [email protected] want: ^2.0.0
273 timing idealTree:node_modules/strip-ansi Completed in 1ms
274 timing idealTree:node_modules/ansi-regex Completed in 0ms
275 timing idealTree:node_modules/strip-json-comments Completed in 0ms
276 silly placeDep ROOT [email protected] OK for: [email protected] want: ^1.1.1
277 silly placeDep ROOT [email protected] OK for: [email protected] want: ^2.1.4
278 silly fetch manifest bl@^4.0.3
279 silly fetch manifest fs-constants@^1.0.0
280 silly fetch manifest readable-stream@^3.1.1
281 http fetch GET 304 https://registry.npmjs.org/fs-constants 65ms (from cache)
282 http fetch GET 304 https://registry.npmjs.org/bl 116ms (from cache)
283 timing idealTree:node_modules/tar-fs Completed in 120ms
284 timing idealTree:node_modules/chownr Completed in 0ms
285 silly placeDep ROOT [email protected] OK for: [email protected] want: ^4.0.3
286 silly placeDep ROOT [email protected] OK for: [email protected] want: ^1.0.0
287 silly placeDep node_modules/tar-stream [email protected] OK for: [email protected] want: ^3.1.1
288 silly fetch manifest buffer@^5.5.0
289 silly fetch manifest readable-stream@^3.4.0
290 http fetch GET 304 https://registry.npmjs.org/buffer 92ms (from cache)
291 timing idealTree:node_modules/tar-stream Completed in 101ms
292 silly placeDep ROOT [email protected] OK for: [email protected] want: ^5.5.0
293 silly placeDep node_modules/bl [email protected] OK for: [email protected] want: ^3.4.0
294 silly fetch manifest base64-js@^1.3.1
295 silly fetch manifest ieee754@^1.1.13
296 http fetch GET 304 https://registry.npmjs.org/base64-js 52ms (from cache)
297 http fetch GET 304 https://registry.npmjs.org/ieee754 126ms (from cache)
298 timing idealTree:node_modules/bl Completed in 131ms
299 silly placeDep ROOT [email protected] OK for: [email protected] want: ^1.3.1
300 silly placeDep ROOT [email protected] OK for: [email protected] want: ^1.1.13
301 timing idealTree:node_modules/buffer Completed in 3ms
302 timing idealTree:node_modules/base64-js Completed in 0ms
303 timing idealTree:node_modules/fs-constants Completed in 0ms
304 timing idealTree:node_modules/ieee754 Completed in 0ms
305 timing idealTree:node_modules/tunnel-agent Completed in 0ms
306 timing idealTree:node_modules/util-deprecate Completed in 0ms
307 timing idealTree:node_modules/which-pm-runs Completed in 0ms
308 timing idealTree:node_modules/wide-align Completed in 0ms
309 timing idealTree:node_modules/wrappy Completed in 0ms
310 timing idealTree:node_modules/yallist Completed in 0ms
311 timing idealTree:node_modules/bl/node_modules/readable-stream Completed in 0ms
312 timing idealTree:node_modules/node-abi/node_modules/semver Completed in 0ms
313 silly placeDep node_modules/prebuild-install [email protected] OK for: [email protected] want: ^4.2.0
314 silly fetch manifest mimic-response@^2.0.0
315 timing idealTree:node_modules/prebuild-install/node_modules/simple-get Completed in 1ms
316 silly placeDep node_modules/prebuild-install [email protected] OK for: [email protected] want: ^2.0.0
317 timing idealTree:node_modules/prebuild-install/node_modules/decompress-response Completed in 3ms
318 timing idealTree:node_modules/prebuild-install/node_modules/mimic-response Completed in 0ms
319 timing idealTree:node_modules/tar-stream/node_modules/readable-stream Completed in 0ms
320 timing idealTree:buildDeps Completed in 3104ms
321 timing idealTree:fixDepFlags Completed in 2ms
322 timing idealTree Completed in 3123ms
323 timing reify:loadTrees Completed in 3125ms
324 timing reify:diffTrees Completed in 2ms
325 silly reify moves {}
326 timing reify:retireShallow Completed in 0ms
327 timing reify:createSparse Completed in 14ms
328 timing reify:loadBundles Completed in 0ms
329 silly tarball no local data for node-abi@https://registry.npmjs.org/node-abi/-/node-abi-2.21.0.tgz. Extracting by manifest.
330 silly tarball no local data for color-string@https://registry.npmjs.org/color-string/-/color-string-1.5.5.tgz. Extracting by manifest.
331 timing reifyNode:node_modules/chownr Completed in 281ms
332 timing reifyNode:node_modules/ansi-regex Completed in 281ms
333 timing reifyNode:node_modules/number-is-nan Completed in 281ms
334 timing reifyNode:node_modules/code-point-at Completed in 281ms
335 timing reifyNode:node_modules/is-fullwidth-code-point Completed in 282ms
336 timing reifyNode:node_modules/process-nextick-args Completed in 281ms
337 timing reifyNode:node_modules/strip-json-comments Completed in 281ms
338 timing reifyNode:node_modules/ini Completed in 280ms
339 timing reifyNode:node_modules/wrappy Completed in 280ms
340 timing reifyNode:node_modules/once Completed in 281ms
341 timing reifyNode:node_modules/end-of-stream Completed in 281ms
342 timing reifyNode:node_modules/which-pm-runs Completed in 281ms
343 timing reifyNode:node_modules/mkdirp-classic Completed in 281ms
344 timing reifyNode:node_modules/wide-align Completed in 281ms
345 timing reifyNode:node_modules/strip-ansi Completed in 281ms
346 timing reifyNode:node_modules/object-assign Completed in 281ms
347 timing reifyNode:node_modules/has-unicode Completed in 282ms
348 timing reifyNode:node_modules/string-width Completed in 282ms
349 timing reifyNode:node_modules/aproba Completed in 282ms
350 timing reifyNode:node_modules/simple-swizzle Completed in 282ms
351 timing reifyNode:node_modules/prebuild-install/node_modules/simple-get Completed in 281ms
352 timing reifyNode:node_modules/fs-constants Completed in 288ms
353 timing reifyNode:node_modules/ieee754 Completed in 289ms
354 timing reifyNode:node_modules/mimic-response Completed in 288ms
355 timing reifyNode:node_modules/decompress-response Completed in 289ms
356 timing reifyNode:node_modules/lru-cache Completed in 289ms
357 timing reifyNode:node_modules/inherits Completed in 288ms
358 timing reifyNode:node_modules/set-blocking Completed in 286ms
359 timing reifyNode:node_modules/console-control-strings Completed in 287ms
360 timing reifyNode:node_modules/simple-get Completed in 287ms
361 timing reifyNode:node_modules/tunnel-agent Completed in 287ms
362 timing reifyNode:node_modules/prebuild-install/node_modules/mimic-response Completed in 286ms
363 timing reifyNode:node_modules/prebuild-install/node_modules/decompress-response Completed in 287ms
364 timing reifyNode:node_modules/color Completed in 287ms
365 timing reifyNode:node_modules/base64-js Completed in 294ms
366 timing reifyNode:node_modules/yallist Completed in 294ms
367 timing reifyNode:node_modules/util-deprecate Completed in 293ms
368 timing reifyNode:node_modules/expand-template Completed in 291ms
369 timing reifyNode:node_modules/signal-exit Completed in 292ms
370 timing reifyNode:node_modules/simple-concat Completed in 298ms
371 timing reifyNode:node_modules/string_decoder Completed in 297ms
372 timing reifyNode:node_modules/safe-buffer Completed in 297ms
373 timing reifyNode:node_modules/deep-extend Completed in 296ms
374 timing reifyNode:node_modules/pump Completed in 296ms
375 timing reifyNode:node_modules/napi-build-utils Completed in 296ms
376 timing reifyNode:node_modules/color-name Completed in 295ms
377 timing reifyNode:node_modules/npmlog Completed in 295ms
378 timing reifyNode:node_modules/is-arrayish Completed in 301ms
379 timing reifyNode:node_modules/isarray Completed in 300ms
380 timing reifyNode:node_modules/core-util-is Completed in 303ms
381 timing reifyNode:node_modules/delegates Completed in 301ms
382 timing reifyNode:node_modules/color-convert Completed in 301ms
383 timing reifyNode:node_modules/noop-logger Completed in 305ms
384 timing reifyNode:node_modules/detect-libc Completed in 303ms
385 timing reifyNode:node_modules/tar-stream Completed in 310ms
386 timing reifyNode:node_modules/node-abi/node_modules/semver Completed in 308ms
387 timing reifyNode:node_modules/are-we-there-yet Completed in 307ms
388 timing reifyNode:node_modules/buffer Completed in 315ms
389 timing reifyNode:node_modules/github-from-package Completed in 319ms
390 timing reifyNode:node_modules/rc Completed in 324ms
391 timing reifyNode:node_modules/bl Completed in 328ms
392 timing reifyNode:node_modules/array-flatten Completed in 323ms
393 timing reifyNode:node_modules/prebuild-install Completed in 328ms
394 http fetch GET 200 https://registry.npmjs.org/color-string/-/color-string-1.5.5.tgz 274ms
395 timing reifyNode:node_modules/color-string Completed in 335ms
396 timing reifyNode:node_modules/minimist Completed in 338ms
397 timing reifyNode:node_modules/gauge Completed in 337ms
398 http fetch GET 200 https://registry.npmjs.org/node-abi/-/node-abi-2.21.0.tgz 293ms
399 timing reifyNode:node_modules/node-abi Completed in 349ms
400 timing reifyNode:node_modules/readable-stream Completed in 353ms
401 timing reifyNode:node_modules/bl/node_modules/readable-stream Completed in 360ms
402 timing reifyNode:node_modules/tar-stream/node_modules/readable-stream Completed in 359ms
403 timing reifyNode:node_modules/tar-fs Completed in 359ms
404 timing reifyNode:node_modules/semver Completed in 363ms
405 timing reifyNode:node_modules/sharp Completed in 366ms
406 timing reifyNode:node_modules/node-addon-api Completed in 376ms
407 timing reify:unpack Completed in 382ms
408 timing reify:unretire Completed in 0ms
409 timing build:queue Completed in 4ms
410 timing build:link:node_modules/detect-libc Completed in 4ms
411 timing build:link:node_modules/node-abi/node_modules/semver Completed in 3ms
412 timing build:link:node_modules/prebuild-install Completed in 3ms
413 timing build:link:node_modules/rc Completed in 3ms
414 timing build:link:node_modules/semver Completed in 3ms
415 timing build:link Completed in 4ms
416 info run [email protected] install node_modules/sharp (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
417 http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/advisories/bulk 952ms
418 timing auditReport:getReport Completed in 953ms
419 timing auditReport:init Completed in 0ms
420 timing reify:audit Completed in 955ms
421 info run [email protected] install { code: 1, signal: null }
422 timing reify:rollback:createSparse Completed in 108ms
423 timing reify:rollback:retireShallow Completed in 0ms
424 timing command:install Completed in 5917ms
425 verbose stack Error: command failed
425 verbose stack     at ChildProcess.<anonymous> (/home/linuxbrew/.linuxbrew/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/index.js:64:27)
425 verbose stack     at ChildProcess.emit (node:events:378:20)
425 verbose stack     at maybeClose (node:internal/child_process:1067:16)
425 verbose stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
426 verbose pkgid [email protected]
427 verbose cwd /tmp/node-snap
428 verbose Linux 5.8.0-44-generic
429 verbose argv "/snap/node/3836/bin/node" "/home/linuxbrew/.linuxbrew/bin/npm" "i" "sharp"
430 verbose node v15.11.0
431 verbose npm  v7.6.0
432 error code 1
433 error path /tmp/node-snap/node_modules/sharp
434 error command failed
435 error command sh -c (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
436 verbose exit 1

I also tried to install Node.js via apt (https://github.com/nodesource/distributions/blob/master/README.md) and via nvm. Both worked. So the issue seems to be the snap.

There is a problem with snaps building addons in that the snap has its own toolchain and set of libraries, so when running node you're not using your standard system libraries, but those that are inside the snap isolation environment. This is just how snaps work and lets them be consistent across OSs and versions, but it leads to dynamic library issues if things don't line up quite right. Generally if you have a complex environment and want to do addons then you're probably better off not using the snap.

What do you consider to be a “complex environment”? Do you think that native extensions like sharp are complex? It’s completely understandable if that’s the case. But I’m not doing anything fancy over here: I just have a fresh Ubuntu installation and the Node.js snap installed via Ubuntu Software.


Thanks for the help over here; it’s nice of you 😄

@rvagg
Copy link
Member

rvagg commented Apr 10, 2021

I ran into this problem myself today and this is how I ended up solving it:

  • Built a simple Docker container based on ubuntu18 (the Node snap is based on core18)
  • Added in the version of Node I was using from the NodeSource distributions (could also just grab a binary tarball from nodejs.org)
  • npm i -g node-gyp
  • Installed make gcc g++
  • Tagged the image

Then using that image:

  • docker run -ti --rm -v $(pwd):/opt <image> bash
  • cd /opt/ (or sub-path you want to rebuild)
  • node-gyp rebuild
  • exit

Then you end up with a binary that's based on the 18.04 toolchain which is good enough for newer systems.

Previously I've resorted to a non-Snap version of node to work around problems like this, but it kind of needs a better answer than that .. this is slightly better.

A thought I had while doing this is that offering some images via Docker Hub for doing this a bit more automatically might be nice. Perhaps an image that you can just docker run -ti --rm -v $(pwd):/opt node-core18-addon-rebuilder and it'll do a node-gyp rebuild in your current directory and exit. A Dockerfile for that should be pretty simple.

@rvagg rvagg mentioned this issue Apr 20, 2021
7 tasks
@hperrin
Copy link

hperrin commented Sep 28, 2021

It seems I'm running into the same issue trying to install Haraka.

root@hperrin-ideapad:~# npm install -g Haraka
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: Please upgrade to @mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped package will recieve updates in the future
npm WARN deprecated [email protected]: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
npm ERR! code 1
npm ERR! path /usr/local/lib/node_modules/Haraka/node_modules/iconv
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-09-28T21_56_29_894Z-debug.log

@rvagg
Copy link
Member

rvagg commented Oct 4, 2021

What do you consider to be a “complex environment”? Do you think that native extensions like sharp are complex?

Actually, to be honest, just a native extension raises the level of complexity enough that this gets annoying really quickly. The Node.js executable is running in a very specific environment, with its own libc and other pieces local to the Snap. Then your addons are built using intelligence garnered from the broader system environment, not properly taking into consideration the constrained environment of the Snap. That's where mismatches happen - the addon gets built assuming that the libraries on the system are 👌 but then Node.js tries to load the addon into its own constrained environment and borks.

A proper fix here is likely going to involve some gnarly work with https://github.com/nodejs/gyp-next and https://github.com/nodejs/node-gyp or maybe an alternative toolchain that can properly take into account the environment when building addons. This is not a simple problem, but I'm sure it's being solved for other platforms/systems that have this dual environment issue where library loading is involved.

Unfortunately I don't know who is going to solve this. Maybe out best bet is to try and loop in folks from the Snap team to see if they have ideas based on experience with other similar setups.

So, very sorry, but I've had to resort to local installs instead of Snap installs whenever I run into problems like this because it gets so messy very quickly when you step outside of vanilla Node.js usage.

@leafac
Copy link
Author

leafac commented Oct 9, 2021

@rvagg Thanks for the information 👍

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

3 participants