Node-gyp on leveldown failed in snap build

I try to build a snap for an ARM device that will host a Node.js API and use Leveldown as backing store.

I’ve transpiled and bundled my sources successfully, before handing it in into the snapcraft build process. The whole thing is using the core18 as base, and is working if I install the bundled nodejs (8.6) and node-leveldown from the Debian repos into the snap image…

…but as these are rather outdated I’m trying to upgrade to a newer Node.js version as part of the snapcraft build right now (12.20.1) and as such need to install leveldown with the option --build-from-source into the snap…

Everything I’ve tried is failing with an issue in the node-gyp-rebuild step though…

Here are my settings from snapcraft.yml:

base: core18
parts:                                                                                                                     
  webserver:                                                                                                        
    plugin: nodejs                                                                                                         
    node-engine: 12.20.1                                                                                                   
    source: ./build/                                                                                                       
    override-build: snapcraftctl build && npm install -g node-gyp && npm install --no-save leveldown --build-from-source   
   build-packages:                                                                                                        
     - build-essential                                                                                                    

and the issue I get is this:

gyp: Call to 'node -e "require('napi-macros')"' returned exit status 0 while in binding.gyp. while trying to load binding.gyp                                           
gyp ERR! configure error                                                                                                                                                
gyp ERR! stack Error: `gyp` failed with exit code: 1                                                                                                                    
gyp ERR! stack     at ChildProcess.onCpExit (/build/parts/webserver/install/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)                  
gyp ERR! stack     at ChildProcess.emit (events.js:314:20)                                                                                                              
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)                                                                            
gyp ERR! System Linux 5.4.0-1037-aws                                                                                                                                    
gyp ERR! command "/build/parts/webserver/install/bin/node" "/build/parts/webserver/install/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"                                                                                                                                                                  
gyp ERR! cwd /build/parts/webserver/build/node_modules/leveldown                                                                                                 
gyp ERR! node -v v12.20.1                                                                                                                                               
gyp ERR! node-gyp -v v5.1.0                                                                                                                                             
gyp ERR! not ok                                                                                                                                                         
                                                                                                                                                                    
npm ERR! code ELIFECYCLE                                                                                                                                                
npm ERR! errno 1                                                                                                                                                        
npm ERR! leveldown@5.6.0 install: `node-gyp-build`                                                                                                                      
npm ERR! Exit status 1                                                                                                                                                  
npm ERR!                                                                                                                                                                
npm ERR! Failed at the leveldown@5.6.0 install script.                                                                                                                  
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.                                                                      

Someone has an idea how I can solve this, or how I’m able to upgrade to a newer nodejs version in the snap package?

Thanks a lot!
Andreas

I think there should be more output above where you started your copy+paste that might indicate what went wrong…

error /build/parts/webserver/build/node_modules/leveldown: Command failed.
Exit code: 1
Command: node-gyp-build
Arguments: 
Directory: /build/parts/webserver/build/node_modules/leveldown
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@5.1.0
gyp info using node@12.20.1 | linux | arm
gyp info find Python using Python version 3.6.9 found at "/usr/bin/python3"
gyp http GET https://nodejs.org/download/release/v12.20.1/node-v12.20.1-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v12.20.1/node-v12.20.1-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v12.20.1/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v12.20.1/SHASUMS256.txt
gyp info spawn /usr/bin/python3
gyp info spawn args [
gyp info spawn args   '/build/parts/webserver/install/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/build/parts/webserver/build/node_modules/leveldown/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/build/parts/webserver/install/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/root/.cache/node-gyp/12.20.1/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/12.20.1',
gyp info spawn args   '-Dnode_gyp_dir=/build/parts/webserver/install/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/12.20.1/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/build/parts/webserver/build/node_modules/leveldown',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]

gyp: Call to 'node -e "require('napi-macros')"' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/build/parts/webserver/install/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:314:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
gyp ERR! System Linux 5.4.0-1037-aws
gyp ERR! command "/build/parts/webserver/install/bin/node" "/build/parts/webserver/install/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /build/parts/webserver/build/node_modules/leveldown
gyp ERR! node -v v12.20.1
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok

That the whole trace of the rebuild process I guess…

We still need to see more above this line. Why did leveldown fail?

There is not much more to see on the screen… I guess this is the trace of the call to

npm install leveldown --build-from-sources

which should trigger a node-gyp-build. The whole snap process is running in a container. I can check for additional logs there.

Ok, just went into the container itself and checked the log generated via the npm install command…

324 verbose lifecycle leveldown@5.6.0~install: unsafe-perm in lifecycle true
325 verbose lifecycle leveldown@5.6.0~install: PATH: /build/parts/webserver/install/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/build/parts/webserver/build/node_modules/leveldown/node_modules/.bin:/build/parts/webserver/build/node_modules/.bin:/build/parts/webserver/install/bin:/build/stage/usr/sbin:/build/stage/usr/bin:/build/stage/sbin:/build/stage/bin:/build/parts/webserver/install/usr/sbin:/build/parts/webserver/install/usr/bin:/build/parts/webserver/install/sbin:/build/parts/webserver/install/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
326 verbose lifecycle leveldown@5.6.0~install: CWD: /build/parts/webserver/build/node_modules/leveldown
327 silly lifecycle leveldown@5.6.0~install: Args: [ '-c', 'node-gyp-build' ]
328 silly lifecycle leveldown@5.6.0~install: Returned: code: 1  signal: null
329 info lifecycle leveldown@5.6.0~install: Failed to exec install script
330 timing action:install Completed in 17020ms
331 verbose unlock done using /root/.npm/_locks/staging-068d0c3a347115d4.lock for /build/parts/webserver/build/node_modules/.staging
332 timing stage:rollbackFailedOptional Completed in 254ms
333 timing stage:runTopLevelLifecycles Completed in 36888ms
334 warn webserver@0.1.0 No repository field.
335 verbose stack Error: leveldown@5.6.0 install: `node-gyp-build`
335 verbose stack Exit status 1
335 verbose stack     at EventEmitter.<anonymous> (/build/parts/webserver/install/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
335 verbose stack     at EventEmitter.emit (events.js:314:20)
335 verbose stack     at ChildProcess.<anonymous> (/build/parts/webserver/install/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
335 verbose stack     at ChildProcess.emit (events.js:314:20)
335 verbose stack     at maybeClose (internal/child_process.js:1022:16)
335 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
336 verbose pkgid leveldown@5.6.0
337 verbose cwd /build/parts/webserver/build
338 verbose Linux 5.4.0-1037-aws
339 verbose argv "/build/parts/webserver/install/bin/node" "/build/parts/webserver/install/bin/npm" "install" "--no-save" "leveldown" "--build-from-source"
340 verbose node v12.20.1
341 verbose npm  v6.14.10
342 error code ELIFECYCLE
343 error errno 1
344 error leveldown@5.6.0 install: `node-gyp-build`
344 error Exit status 1
345 error Failed at the leveldown@5.6.0 install script.
345 error This is probably not a problem with npm. There is likely additional logging output above.
346 verbose exit [ 1, true ]

we need to go further back in the log, still. I can see that the install step failed, but the error is before the point you started your copy+paste.

hmmm the rest looks like usual prefetch and unpack package work to me… here you go…

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/build/parts/webserver/install/bin/node',
1 verbose cli   '/build/parts/webserver/install/bin/npm',
1 verbose cli   'install',
1 verbose cli   '--no-save',
1 verbose cli   'leveldown',
1 verbose cli   '--build-from-source'
1 verbose cli ]
2 info using npm@6.14.10
3 info using node@v12.20.1
4 verbose npm-session 187162eb59f075d5
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 200 https://registry.npmjs.org/leveldown 5601ms
8 http fetch GET 200 https://registry.npmjs.org/leveldown/-/leveldown-5.6.0.tgz 922ms
9 silly pacote tag manifest for leveldown@latest fetched in 6628ms
10 timing stage:loadCurrentTree Completed in 6879ms
11 silly install loadIdealTree
12 silly install cloneCurrentTreeToIdealTree
13 timing stage:loadIdealTree:cloneCurrentTree Completed in 2ms
14 silly install loadShrinkwrap
15 timing stage:loadIdealTree:loadShrinkwrap Completed in 7ms
16 silly install loadAllDepsIntoIdealTree
17 silly resolveWithNewModule leveldown@5.6.0 checking installable status
18 http fetch GET 200 https://registry.npmjs.org/abstract-leveldown 161ms
19 http fetch GET 200 https://registry.npmjs.org/abstract-leveldown/-/abstract-leveldown-6.2.3.tgz 157ms
20 silly pacote range manifest for abstract-leveldown@~6.2.1 fetched in 356ms
21 silly resolveWithNewModule abstract-leveldown@6.2.3 checking installable status
22 http fetch GET 200 https://registry.npmjs.org/napi-macros 5251ms
23 http fetch GET 200 https://registry.npmjs.org/node-gyp-build 5270ms
24 http fetch GET 200 https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.1.1.tgz 424ms
25 http fetch GET 200 https://registry.npmjs.org/napi-macros/-/napi-macros-2.0.0.tgz 473ms
26 silly pacote range manifest for node-gyp-build@~4.1.0 fetched in 5772ms
27 silly resolveWithNewModule node-gyp-build@4.1.1 checking installable status
28 silly pacote range manifest for napi-macros@~2.0.0 fetched in 5784ms
29 silly resolveWithNewModule napi-macros@2.0.0 checking installable status
30 http fetch GET 200 https://registry.npmjs.org/immediate 170ms
31 http fetch GET 200 https://registry.npmjs.org/level-concat-iterator 173ms
32 http fetch GET 200 https://registry.npmjs.org/buffer 190ms
33 http fetch GET 200 https://registry.npmjs.org/immediate/-/immediate-3.3.0.tgz 113ms
34 http fetch GET 200 https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz 91ms
35 http fetch GET 200 https://registry.npmjs.org/level-concat-iterator/-/level-concat-iterator-2.0.1.tgz 106ms
36 silly pacote range manifest for immediate@^3.2.3 fetched in 319ms
37 silly pacote range manifest for buffer@^5.5.0 fetched in 324ms
38 silly resolveWithNewModule immediate@3.3.0 checking installable status
39 silly resolveWithNewModule buffer@5.7.1 checking installable status
40 silly pacote range manifest for level-concat-iterator@~2.0.0 fetched in 322ms
41 silly resolveWithNewModule level-concat-iterator@2.0.1 checking installable status
42 http fetch GET 200 https://registry.npmjs.org/xtend 5151ms
43 http fetch GET 200 https://registry.npmjs.org/level-supports 5163ms
44 http fetch GET 200 https://registry.npmjs.org/level-supports/-/level-supports-1.0.1.tgz 66ms
45 http fetch GET 200 https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz 80ms
46 silly pacote range manifest for level-supports@~1.0.0 fetched in 5252ms
47 silly resolveWithNewModule level-supports@1.0.1 checking installable status
48 silly pacote range manifest for xtend@~4.0.0 fetched in 5253ms
49 silly resolveWithNewModule xtend@4.0.2 checking installable status
50 http fetch GET 200 https://registry.npmjs.org/ieee754 55ms
51 http fetch GET 200 https://registry.npmjs.org/base64-js 61ms
52 http fetch GET 200 https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz 121ms
53 http fetch GET 200 https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz 70ms
54 silly pacote range manifest for ieee754@^1.1.13 fetched in 199ms
55 silly resolveWithNewModule ieee754@1.2.1 checking installable status
56 silly pacote range manifest for base64-js@^1.3.1 fetched in 205ms
57 silly resolveWithNewModule base64-js@1.5.1 checking installable status
58 timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 11375ms
59 timing stage:loadIdealTree Completed in 11415ms
60 silly currentTree webserver@0.1.0
61 silly idealTree webserver@0.1.0
61 silly idealTree ├── abstract-leveldown@6.2.3
61 silly idealTree ├── base64-js@1.5.1
61 silly idealTree ├── buffer@5.7.1
61 silly idealTree ├── ieee754@1.2.1
61 silly idealTree ├── immediate@3.3.0
61 silly idealTree ├── level-concat-iterator@2.0.1
61 silly idealTree ├── level-supports@1.0.1
61 silly idealTree ├── leveldown@5.6.0
61 silly idealTree ├── napi-macros@2.0.0
61 silly idealTree ├── node-gyp-build@4.1.1
61 silly idealTree └── xtend@4.0.2
62 silly install generateActionsToTake
63 timing stage:generateActionsToTake Completed in 41ms
64 silly diffTrees action count 11
65 silly diffTrees add base64-js@1.5.1
66 silly diffTrees add ieee754@1.2.1
67 silly diffTrees add buffer@5.7.1
68 silly diffTrees add immediate@3.3.0
69 silly diffTrees add level-concat-iterator@2.0.1
70 silly diffTrees add xtend@4.0.2
71 silly diffTrees add level-supports@1.0.1
72 silly diffTrees add abstract-leveldown@6.2.3
73 silly diffTrees add napi-macros@2.0.0
74 silly diffTrees add node-gyp-build@4.1.1
75 silly diffTrees add leveldown@5.6.0
76 silly decomposeActions action count 88
77 silly decomposeActions fetch base64-js@1.5.1
78 silly decomposeActions extract base64-js@1.5.1
79 silly decomposeActions preinstall base64-js@1.5.1
80 silly decomposeActions build base64-js@1.5.1
81 silly decomposeActions install base64-js@1.5.1
82 silly decomposeActions postinstall base64-js@1.5.1
83 silly decomposeActions finalize base64-js@1.5.1
84 silly decomposeActions refresh-package-json base64-js@1.5.1
85 silly decomposeActions fetch ieee754@1.2.1
86 silly decomposeActions extract ieee754@1.2.1
87 silly decomposeActions preinstall ieee754@1.2.1
88 silly decomposeActions build ieee754@1.2.1
89 silly decomposeActions install ieee754@1.2.1
90 silly decomposeActions postinstall ieee754@1.2.1
91 silly decomposeActions finalize ieee754@1.2.1
92 silly decomposeActions refresh-package-json ieee754@1.2.1
93 silly decomposeActions fetch buffer@5.7.1
94 silly decomposeActions extract buffer@5.7.1
95 silly decomposeActions preinstall buffer@5.7.1
96 silly decomposeActions build buffer@5.7.1
97 silly decomposeActions install buffer@5.7.1
98 silly decomposeActions postinstall buffer@5.7.1
99 silly decomposeActions finalize buffer@5.7.1
100 silly decomposeActions refresh-package-json buffer@5.7.1
101 silly decomposeActions fetch immediate@3.3.0
102 silly decomposeActions extract immediate@3.3.0
103 silly decomposeActions preinstall immediate@3.3.0
104 silly decomposeActions build immediate@3.3.0
105 silly decomposeActions install immediate@3.3.0
106 silly decomposeActions postinstall immediate@3.3.0
107 silly decomposeActions finalize immediate@3.3.0
108 silly decomposeActions refresh-package-json immediate@3.3.0
109 silly decomposeActions fetch level-concat-iterator@2.0.1
110 silly decomposeActions extract level-concat-iterator@2.0.1
111 silly decomposeActions preinstall level-concat-iterator@2.0.1
112 silly decomposeActions build level-concat-iterator@2.0.1
113 silly decomposeActions install level-concat-iterator@2.0.1
114 silly decomposeActions postinstall level-concat-iterator@2.0.1
115 silly decomposeActions finalize level-concat-iterator@2.0.1
116 silly decomposeActions refresh-package-json level-concat-iterator@2.0.1
117 silly decomposeActions fetch xtend@4.0.2
118 silly decomposeActions extract xtend@4.0.2
119 silly decomposeActions preinstall xtend@4.0.2
120 silly decomposeActions build xtend@4.0.2
121 silly decomposeActions install xtend@4.0.2
122 silly decomposeActions postinstall xtend@4.0.2
123 silly decomposeActions finalize xtend@4.0.2
124 silly decomposeActions refresh-package-json xtend@4.0.2
125 silly decomposeActions fetch level-supports@1.0.1
126 silly decomposeActions extract level-supports@1.0.1
127 silly decomposeActions preinstall level-supports@1.0.1
128 silly decomposeActions build level-supports@1.0.1
129 silly decomposeActions install level-supports@1.0.1
130 silly decomposeActions postinstall level-supports@1.0.1
131 silly decomposeActions finalize level-supports@1.0.1
132 silly decomposeActions refresh-package-json level-supports@1.0.1
133 silly decomposeActions fetch abstract-leveldown@6.2.3
134 silly decomposeActions extract abstract-leveldown@6.2.3
135 silly decomposeActions preinstall abstract-leveldown@6.2.3
136 silly decomposeActions build abstract-leveldown@6.2.3
137 silly decomposeActions install abstract-leveldown@6.2.3
138 silly decomposeActions postinstall abstract-leveldown@6.2.3
139 silly decomposeActions finalize abstract-leveldown@6.2.3
140 silly decomposeActions refresh-package-json abstract-leveldown@6.2.3
141 silly decomposeActions fetch napi-macros@2.0.0
142 silly decomposeActions extract napi-macros@2.0.0
143 silly decomposeActions preinstall napi-macros@2.0.0
144 silly decomposeActions build napi-macros@2.0.0
145 silly decomposeActions install napi-macros@2.0.0
146 silly decomposeActions postinstall napi-macros@2.0.0
147 silly decomposeActions finalize napi-macros@2.0.0
148 silly decomposeActions refresh-package-json napi-macros@2.0.0
149 silly decomposeActions fetch node-gyp-build@4.1.1
150 silly decomposeActions extract node-gyp-build@4.1.1
151 silly decomposeActions preinstall node-gyp-build@4.1.1
152 silly decomposeActions build node-gyp-build@4.1.1
153 silly decomposeActions install node-gyp-build@4.1.1
154 silly decomposeActions postinstall node-gyp-build@4.1.1
155 silly decomposeActions finalize node-gyp-build@4.1.1
156 silly decomposeActions refresh-package-json node-gyp-build@4.1.1
157 silly decomposeActions fetch leveldown@5.6.0
158 silly decomposeActions extract leveldown@5.6.0
159 silly decomposeActions preinstall leveldown@5.6.0
160 silly decomposeActions build leveldown@5.6.0
161 silly decomposeActions install leveldown@5.6.0
162 silly decomposeActions postinstall leveldown@5.6.0
163 silly decomposeActions finalize leveldown@5.6.0
164 silly decomposeActions refresh-package-json leveldown@5.6.0
165 silly install executeActions
166 silly doSerial global-install 88
167 verbose correctMkdir /root/.npm/_locks correctMkdir not in flight; initializing
168 verbose lock using /root/.npm/_locks/staging-068d0c3a347115d4.lock for /build/parts/webserver/build/node_modules/.staging
169 silly doParallel extract 11
170 silly extract base64-js@1.5.1
171 silly extract ieee754@1.2.1
172 silly extract buffer@5.7.1
173 silly extract immediate@3.3.0
174 silly extract level-concat-iterator@2.0.1
175 silly extract xtend@4.0.2
176 silly extract level-supports@1.0.1
177 silly extract abstract-leveldown@6.2.3
178 silly extract napi-macros@2.0.0
179 silly extract node-gyp-build@4.1.1
180 silly extract leveldown@5.6.0
181 silly tarball trying base64-js@^1.3.1 by hash: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==
182 silly tarball trying ieee754@^1.1.13 by hash: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==
183 silly tarball trying buffer@^5.5.0 by hash: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==
184 silly tarball trying immediate@^3.2.3 by hash: sha512-HR7EVodfFUdQCTIeySw+WDRFJlPcLOJbXfwwZ7Oom6tjsvZ3bOkCDJHehQC3nxJrv7+f9XecwazynjU8e4Vw3Q==
185 silly tarball trying level-concat-iterator@~2.0.0 by hash: sha512-OTKKOqeav2QWcERMJR7IS9CUo1sHnke2C0gkSmcR7QuEtFNLLzHQAvnMw8ykvEcv0Qtkg0p7FOwP1v9e5Smdcw==
186 silly tarball trying xtend@~4.0.0 by hash: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==
187 silly tarball trying level-supports@~1.0.0 by hash: sha512-rXM7GYnW8gsl1vedTJIbzOrRv85c/2uCMpiiCzO2fndd06U/kUXEEU9evYn4zFggBOg36IsBW8LzqIpETwwQzg==
188 silly tarball trying abstract-leveldown@~6.2.1 by hash: sha512-BsLm5vFMRUrrLeCcRc+G0t2qOaTzpoJQLOubq2XM72eNpjF5UdU5o/5NvlNhx95XHcAvcl8OMXr4mlg/fRgUXQ==
189 silly tarball trying napi-macros@~2.0.0 by hash: sha512-A0xLykHtARfueITVDernsAWdtIMbOJgKgcluwENp3AlsKN/PloyO10HtmoqnFAQAcxPkgZN7wdfPfEd0zNGxbg==
190 silly tarball trying node-gyp-build@~4.1.0 by hash: sha512-dSq1xmcPDKPZ2EED2S6zw/b9NKsqzXRE6dVr8TVQnI3FJOTteUMuqF3Qqs6LZg+mLGYJWqQzMbIjMtJqTv87nQ==
191 silly tarball trying leveldown@latest by hash: sha512-iB8O/7Db9lPaITU1aA2txU/cBEXAt4vWwKQRrrWuS6XDgbP4QZGj9BL2aNbwb002atoQ/lIotJkfyzz+ygQnUQ==
192 timing audit submit Completed in 445ms
193 http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/audits/quick 440ms
194 timing audit body Completed in 6ms
195 silly extract base64-js@^1.3.1 extracted to /build/parts/webserver/build/node_modules/.staging/base64-js-8ab1fddc (383ms)
196 silly extract ieee754@^1.1.13 extracted to /build/parts/webserver/build/node_modules/.staging/ieee754-bbb2b0f9 (389ms)
197 silly extract xtend@~4.0.0 extracted to /build/parts/webserver/build/node_modules/.staging/xtend-57c5de56 (394ms)
198 silly extract node-gyp-build@~4.1.0 extracted to /build/parts/webserver/build/node_modules/.staging/node-gyp-build-59410a43 (390ms)
199 silly extract level-supports@~1.0.0 extracted to /build/parts/webserver/build/node_modules/.staging/level-supports-4c1269d2 (404ms)
200 silly extract level-concat-iterator@~2.0.0 extracted to /build/parts/webserver/build/node_modules/.staging/level-concat-iterator-fc584748 (409ms)
201 silly extract napi-macros@~2.0.0 extracted to /build/parts/webserver/build/node_modules/.staging/napi-macros-5ebb9816 (404ms)
202 silly extract buffer@^5.5.0 extracted to /build/parts/webserver/build/node_modules/.staging/buffer-183ec76e (414ms)
203 silly extract immediate@^3.2.3 extracted to /build/parts/webserver/build/node_modules/.staging/immediate-57da1f4b (419ms)
204 silly extract abstract-leveldown@~6.2.1 extracted to /build/parts/webserver/build/node_modules/.staging/abstract-leveldown-dbde4929 (443ms)
205 silly extract leveldown@latest extracted to /build/parts/webserver/build/node_modules/.staging/leveldown-ffffbf9a (863ms)
206 timing action:extract Completed in 889ms
207 silly doReverseSerial unbuild 88
208 silly doSerial remove 88
209 silly doSerial move 88
210 silly doSerial finalize 88
211 silly finalize /build/parts/webserver/build/node_modules/base64-js
212 silly finalize /build/parts/webserver/build/node_modules/ieee754
213 silly finalize /build/parts/webserver/build/node_modules/buffer
214 silly finalize /build/parts/webserver/build/node_modules/immediate
215 silly finalize /build/parts/webserver/build/node_modules/level-concat-iterator
216 silly finalize /build/parts/webserver/build/node_modules/xtend
217 silly finalize /build/parts/webserver/build/node_modules/level-supports
218 silly finalize /build/parts/webserver/build/node_modules/abstract-leveldown
219 silly finalize /build/parts/webserver/build/node_modules/napi-macros
220 silly finalize /build/parts/webserver/build/node_modules/node-gyp-build
221 silly finalize /build/parts/webserver/build/node_modules/leveldown
222 timing action:finalize Completed in 55ms
223 silly doParallel refresh-package-json 11
224 silly refresh-package-json /build/parts/webserver/build/node_modules/base64-js
225 silly refresh-package-json /build/parts/webserver/build/node_modules/ieee754
226 silly refresh-package-json /build/parts/webserver/build/node_modules/buffer
227 silly refresh-package-json /build/parts/webserver/build/node_modules/immediate
228 silly refresh-package-json /build/parts/webserver/build/node_modules/level-concat-iterator
229 silly refresh-package-json /build/parts/webserver/build/node_modules/xtend
230 silly refresh-package-json /build/parts/webserver/build/node_modules/level-supports
231 silly refresh-package-json /build/parts/webserver/build/node_modules/abstract-leveldown
232 silly refresh-package-json /build/parts/webserver/build/node_modules/napi-macros
233 silly refresh-package-json /build/parts/webserver/build/node_modules/node-gyp-build
234 silly refresh-package-json /build/parts/webserver/build/node_modules/leveldown
235 timing action:refresh-package-json Completed in 162ms
236 silly doParallel preinstall 11
237 silly preinstall base64-js@1.5.1
238 info lifecycle base64-js@1.5.1~preinstall: base64-js@1.5.1
239 silly preinstall ieee754@1.2.1
240 info lifecycle ieee754@1.2.1~preinstall: ieee754@1.2.1
241 silly preinstall buffer@5.7.1
242 info lifecycle buffer@5.7.1~preinstall: buffer@5.7.1
243 silly preinstall immediate@3.3.0
244 info lifecycle immediate@3.3.0~preinstall: immediate@3.3.0
245 silly preinstall level-concat-iterator@2.0.1
246 info lifecycle level-concat-iterator@2.0.1~preinstall: level-concat-iterator@2.0.1
247 silly preinstall xtend@4.0.2
248 info lifecycle xtend@4.0.2~preinstall: xtend@4.0.2
249 silly preinstall level-supports@1.0.1
250 info lifecycle level-supports@1.0.1~preinstall: level-supports@1.0.1
251 silly preinstall abstract-leveldown@6.2.3
252 info lifecycle abstract-leveldown@6.2.3~preinstall: abstract-leveldown@6.2.3
253 silly preinstall napi-macros@2.0.0
254 info lifecycle napi-macros@2.0.0~preinstall: napi-macros@2.0.0
255 silly preinstall node-gyp-build@4.1.1
256 info lifecycle node-gyp-build@4.1.1~preinstall: node-gyp-build@4.1.1
257 silly preinstall leveldown@5.6.0
258 info lifecycle leveldown@5.6.0~preinstall: leveldown@5.6.0
259 timing action:preinstall Completed in 16ms
260 silly doSerial build 88
261 silly build base64-js@1.5.1
262 info linkStuff base64-js@1.5.1
263 silly linkStuff base64-js@1.5.1 has /build/parts/webserver/build/node_modules as its parent node_modules
264 silly build ieee754@1.2.1
265 info linkStuff ieee754@1.2.1
266 silly linkStuff ieee754@1.2.1 has /build/parts/webserver/build/node_modules as its parent node_modules
267 silly build buffer@5.7.1
268 info linkStuff buffer@5.7.1
269 silly linkStuff buffer@5.7.1 has /build/parts/webserver/build/node_modules as its parent node_modules
270 silly build immediate@3.3.0
271 info linkStuff immediate@3.3.0
272 silly linkStuff immediate@3.3.0 has /build/parts/webserver/build/node_modules as its parent node_modules
273 silly build level-concat-iterator@2.0.1
274 info linkStuff level-concat-iterator@2.0.1
275 silly linkStuff level-concat-iterator@2.0.1 has /build/parts/webserver/build/node_modules as its parent node_modules
276 silly build xtend@4.0.2
277 info linkStuff xtend@4.0.2
278 silly linkStuff xtend@4.0.2 has /build/parts/webserver/build/node_modules as its parent node_modules
279 silly build level-supports@1.0.1
280 info linkStuff level-supports@1.0.1
281 silly linkStuff level-supports@1.0.1 has /build/parts/webserver/build/node_modules as its parent node_modules
282 silly build abstract-leveldown@6.2.3
283 info linkStuff abstract-leveldown@6.2.3
284 silly linkStuff abstract-leveldown@6.2.3 has /build/parts/webserver/build/node_modules as its parent node_modules
285 silly build napi-macros@2.0.0
286 info linkStuff napi-macros@2.0.0
287 silly linkStuff napi-macros@2.0.0 has /build/parts/webserver/build/node_modules as its parent node_modules
288 silly build node-gyp-build@4.1.1
289 info linkStuff node-gyp-build@4.1.1
290 silly linkStuff node-gyp-build@4.1.1 has /build/parts/webserver/build/node_modules as its parent node_modules
291 verbose linkBins [
291 verbose linkBins   {
291 verbose linkBins     'node-gyp-build': 'bin.js',
291 verbose linkBins     'node-gyp-build-optional': 'optional.js',
291 verbose linkBins     'node-gyp-build-test': 'build-test.js'
291 verbose linkBins   },
291 verbose linkBins   '/build/parts/webserver/build/node_modules/.bin',
291 verbose linkBins   false
291 verbose linkBins ]
292 silly gently link link does not already exist {
292 silly gently link   link: '/build/parts/webserver/build/node_modules/.bin/node-gyp-build',
292 silly gently link   target: '/build/parts/webserver/build/node_modules/node-gyp-build/bin.js'
292 silly gently link }
293 silly gently link link does not already exist {
293 silly gently link   link: '/build/parts/webserver/build/node_modules/.bin/node-gyp-build-optional',
293 silly gently link   target: '/build/parts/webserver/build/node_modules/node-gyp-build/optional.js'
293 silly gently link }
294 silly gently link link does not already exist {
294 silly gently link   link: '/build/parts/webserver/build/node_modules/.bin/node-gyp-build-test',
294 silly gently link   target: '/build/parts/webserver/build/node_modules/node-gyp-build/build-test.js'
294 silly gently link }
295 silly build leveldown@5.6.0
296 info linkStuff leveldown@5.6.0
297 silly linkStuff leveldown@5.6.0 has /build/parts/webserver/build/node_modules as its parent node_modules
298 timing action:build Completed in 49ms
299 silly doSerial global-link 88
300 silly doParallel update-linked 0
301 silly doSerial install 88
302 silly install base64-js@1.5.1
303 info lifecycle base64-js@1.5.1~install: base64-js@1.5.1
304 silly install ieee754@1.2.1
305 info lifecycle ieee754@1.2.1~install: ieee754@1.2.1
306 silly install buffer@5.7.1
307 info lifecycle buffer@5.7.1~install: buffer@5.7.1
308 silly install immediate@3.3.0
309 info lifecycle immediate@3.3.0~install: immediate@3.3.0
310 silly install level-concat-iterator@2.0.1
311 info lifecycle level-concat-iterator@2.0.1~install: level-concat-iterator@2.0.1
312 silly install xtend@4.0.2
313 info lifecycle xtend@4.0.2~install: xtend@4.0.2
314 silly install level-supports@1.0.1
315 info lifecycle level-supports@1.0.1~install: level-supports@1.0.1
316 silly install abstract-leveldown@6.2.3
317 info lifecycle abstract-leveldown@6.2.3~install: abstract-leveldown@6.2.3
318 silly install napi-macros@2.0.0
319 info lifecycle napi-macros@2.0.0~install: napi-macros@2.0.0
320 silly install node-gyp-build@4.1.1
321 info lifecycle node-gyp-build@4.1.1~install: node-gyp-build@4.1.1
322 silly install leveldown@5.6.0
323 info lifecycle leveldown@5.6.0~install: leveldown@5.6.0
324 verbose lifecycle leveldown@5.6.0~install: unsafe-perm in lifecycle true
325 verbose lifecycle leveldown@5.6.0~install: PATH: /build/parts/webserver/install/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/build/parts/webserver/build/node_modules/leveldown/node_modules/.bin:/build/parts/webserver/build/node_modules/.bin:/build/stage/usr/sbin:/build/stage/usr/bin:/build/stage/sbin:/build/stage/bin:/build/parts/webserver/install/usr/sbin:/build/parts/webserver/install/usr/bin:/build/parts/webserver/install/sbin:/build/parts/webserver/install/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
326 verbose lifecycle leveldown@5.6.0~install: CWD: /build/parts/webserver/build/node_modules/leveldown
327 silly lifecycle leveldown@5.6.0~install: Args: [ '-c', 'node-gyp-build' ]
328 silly lifecycle leveldown@5.6.0~install: Returned: code: 1  signal: null
329 info lifecycle leveldown@5.6.0~install: Failed to exec install script
330 timing action:install Completed in 17073ms
331 verbose unlock done using /root/.npm/_locks/staging-068d0c3a347115d4.lock for /build/parts/webserver/build/node_modules/.staging
332 timing stage:rollbackFailedOptional Completed in 252ms
333 timing stage:runTopLevelLifecycles Completed in 37001ms
334 warn webserver@0.1.0 No repository field.
335 verbose stack Error: leveldown@5.6.0 install: `node-gyp-build`
335 verbose stack Exit status 1
335 verbose stack     at EventEmitter.<anonymous> (/build/parts/webserver/install/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
335 verbose stack     at EventEmitter.emit (events.js:314:20)
335 verbose stack     at ChildProcess.<anonymous> (/build/parts/webserver/install/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
335 verbose stack     at ChildProcess.emit (events.js:314:20)
335 verbose stack     at maybeClose (internal/child_process.js:1022:16)
335 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
336 verbose pkgid leveldown@5.6.0
337 verbose cwd /build/parts/webserver/build
338 verbose Linux 5.4.0-1037-aws
339 verbose argv "/build/parts/webserver/install/bin/node" "/build/parts/webserver/install/bin/npm" "install" "--no-save" "leveldown" "--build-from-source"
340 verbose node v12.20.1
341 verbose npm  v6.14.10
342 error code ELIFECYCLE
343 error errno 1
344 error leveldown@5.6.0 install: `node-gyp-build`
344 error Exit status 1
345 error Failed at the leveldown@5.6.0 install script.
345 error This is probably not a problem with npm. There is likely additional logging output above.
346 verbose exit [ 1, true ]

Is your source code public anywhere that I can download and have a play to see if I can figure out what’s up? You’re right in that the log seems to tell us that it failed but no actual helpful messages as to why it failed.

No, it’s not… but as mentioned in the first post the current process is bundling / transpiling the REST API app (ES2016/TS) anyway before handing it in (source: ./build/) into the snap build process - only exception is leveldown as this requires a native (node.js) addon and needs to be compiled for the target architecture / os (which is actually the step in the override-build command line).

So I guess you can just use an empty Node.js project and try the parts definition from above:

It uses this for building it for armhf on x64: https://github.com/dawidcrivelli/snapcraft_armhf

It looks like those container images are very out of date, and based on Ubuntu 16.04 (core). That means that the final image, if it built, would be inoperable due to your stating that you want a core18 image in your yaml.

The following works for me in a native ARM system (raspberry pi 4):

  my-part:
    plugin: nodejs
    nodejs-version: 12.20.1
    nodejs-package-manager: npm
    source: .
    override-build: |
      snapcraftctl build
      ../npm/bin/npm install --no-save leveldown --build-from-source

You should notice that the syntax of the nodejs options are different to what you have. This is because the version of snapcraft in those container images is from before bases were available. By specifying the base: keyword you’ve opted into the newer syntax, but because you’re using a snapcraft from before bases it was expecting and working correctly with the old syntax.

hmmm we just upgraded from the original xenial to bionic in our dockerfile

 File: snapcraft_armhf/Dockerfile.ubuntu_bionic
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 # armhf related docker files!
 FROM multiarch/ubuntu-core:armhf-bionic as snaparm-bionic
 
 # Prepare the cross build binaries
 COPY bin/* /usr/bin/
 # NPM settings for permissions under snap and cross-compilation
 COPY npmrc /root/.npmrc
 WORKDIR /build
 
 # Install snapcraft and compilers
 RUN [ "cross-build-start" ]
 RUN apt-get update && apt-get -y install snapcraft bluez libbluetooth-dev build-essential git libudev-dev zlib1g-dev 
 
 CMD snapcraft clean && snapcraft

I noticed though that the config options available to me didn’t fit to what you might find on the documentation page(s)… :thinking:

the snapcraft deb is horribly outdated, this will also cause issues …

Is there a way to upgrade those on 18.04, which is the latest LTS we are still using here…?

snapcraft is nowadays provided as a snap (updating .deb packages in a stable release is rather painful and binds a lot of resources, snap packages are not bound to a certain release or distro).

snap install snapcraft --classic

should get you the latest binary installed …

OK, I got it running. Used a debootstrap environment with build-chain and nodejs version required by the runtime and build the leveldown addon in it successfully.

Just packaged the result up and included it in the snapcraft build file. Just tested it on the device. Works fine.