Nproc: Permission denied'

My app is already in Snap store and the app is strictly confined (snapcraft.yaml).

In latest change I would like to use “nproc”. However, if I build snap with these changes and install it and connect to my existing interfaces:

sudo snap connect auto-cpufreq:cpu-control
sudo snap connect auto-cpufreq:system-observe
sudo snap connect auto-cpufreq:hardware-observe

I’ll run into following error:

sudo auto-cpufreq --live


Linux distro: Ubuntu 20.04.1 LTS (Focal Fossa)
Linux kernel: 5.4.0-47-generic

Procesor: Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
Traceback (most recent call last):
  File "/snap/auto-cpufreq/x1/bin/auto-cpufreq", line 141, in <module>
  File "/snap/auto-cpufreq/x1/lib/python3.8/site-packages/click/", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/snap/auto-cpufreq/x1/lib/python3.8/site-packages/click/", line 782, in main
    rv = self.invoke(ctx)
  File "/snap/auto-cpufreq/x1/lib/python3.8/site-packages/click/", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/snap/auto-cpufreq/x1/lib/python3.8/site-packages/click/", line 610, in invoke
    return callback(*args, **kwargs)
  File "/snap/auto-cpufreq/x1/bin/auto-cpufreq", line 81, in main
  File "/snap/auto-cpufreq/x1/lib/python3.8/site-packages/source/", line 467, in sysinfo
    total_cpu_count = int(getoutput("nproc --all"))
ValueError: invalid literal for int() with base 10: '/bin/sh: 1: nproc: Permission denied'

If I install the snap using --devmode then I won’t face this problem. Could someone help me identify which plugs I need to add in order to be able to use nproc?


You probably need to stage nproc into your snap, it is part of the base snaps, but there is not an interface to use it, perhaps it could be added but in the meantime it should just work to use stage-packages: [coreutils] inside your snapcraft.yaml to use $SNAP/usr/bin/nproc instead of /usr/bin/nproc directly