I figured a kind of work around; though I don’t like it. It feels like it’s bypassing a lot of what the plugin is supposed to do and I suspect it may be brittle, but here it is:
name: cli-worm
base: core20
version: '0.2.0'
summary: an epub reader for the command line
description: |
A simple command line ncurses style interface for reading epubs
grade: stable
confinement: strict
apps:
cli-worm:
command: bin/cli-worm
plugs:
- home
- removable-media
parts:
cli-worm:
source: .
plugin: npm
npm-node-version: 14.8.0
override-build: |
echo 'build start'
echo "https://nodejs.org/dist/v14.8.0/node-v14.8.0-linux-$ARCH.tar.gz"
curl -s https://nodejs.org/dist/v14.8.0/node-v14.8.0-linux-x64.tar.gz | tar xzf - -C "$SNAPCRAFT_PART_INSTALL" --strip-components=1
npm config set user 0
npm config set unsafe-perm true
npm install
npm install -g --prefix "${SNAPCRAFT_PART_INSTALL}" $(npm pack . | tail -1)
echo 'build end'
stage-packages:
- w3m # used to render xhtml to cli safe text
- node-pre-gyp
The main difference is that I’m no longer invoking snapcraftctl build at all. I’m instead dowloading and invoking the correct version of node myself, allowing me to use node config ahead of running npm install.
Ideally I’d like to not have to subvert the entire build stage in order to run
npm config set user 0
npm config set unsafe-perm true
or event better I’d like a way to build the snap such that I don’t have to alter the npm config at all. I’m guessing this has something to do with what user the snapcraft scripts are using to invoke the build, but there is a lot a I don’t fully understand about this process.