Level / leveldown

Pure C++ Node.js LevelDB binding. An abstract-leveldown compliant store.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Install with --build-from-source failed during snap build

appelgriebsch opened this issue · comments

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:

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 ]

Does someone has an idea how I can solve or further investigate this issue ?

I'm not exactly sure but there might be some issues running this as root. See e.g. https://github.com/sass/node-sass/blob/master/TROUBLESHOOTING.md#running-with-sudo-or-as-root

Can you just try adding --unsafe-perm to see if it helps? I guess to both npm install commands.

OK, definitely seems to be an issue with the snapcraft build environment. Just created a debootstrap root, installed the necessary build-tools and was able to install leveldown with the build-from-source parameter successfully. Closing it.

OK, definitely seems to be an issue with the snapcraft build environment. Just created a debootstrap root, installed the necessary build-tools and was able to install leveldown with the build-from-source parameter successfully. Closing it.

Sweet. Good luck!